0
votes

Im building a very custom CMS on top of Symfony CMF Components/Bundles. I read almost everything i could about the CMF Components/Bundles and i have the "architecture" kinda defined. Im experienced/familiarized with Symfony2 components.

The CMS should provide a way to manage multiple sites. A Site contains Pages. A Page, requires a title and may have content. A page can also have blocks associated(Those already provided by the Block Bundle, and others with custom functionality developed by me for the CMS).

For now i defined two Documents(Site and Page). Based on the application requirements im using the CoreBundle, BlockBundle, RoutingBundle, DoctrinePHPCRBundle, and DoctrinePHPCRAdminBundle.

Based on this requirements the expected Repository Tree should be something like:

/sites
    /site1 ( nodename of the Site Document )
         /pages ( all pages of this site )
              /page1 ( nodename of a Page Document )
              /page2
         /routes ( all routes of this site )
    /site2
        /pages
  ...

The configurations for CoreBundle:

cmf_core:
        persistence:
            phpcr:
                basepath: /sites
                enabled: true

Because i need nodes(/pages, /routes) for each site, how can i initialize them? My first idea was onPostPersist event of a Site document i initialize the required nodes.

use PHPCR\Util\NodeHelper;

...

public function initSiteNodes(ManagerRegistry $registry, Site $site)
    {
        $session = $registry->getConnection();

        NodeHelper::createPath($session, $site->getId()./pages);
        NodeHelper::createPath($session, $site->getId()./routes);

        $session->save();
    }

So my questions are:

Is this architecture feasible and is SonataAdminBundle prepared for such a structure?

1

1 Answers

2
votes

Great to hear you are building a custom CMS on top of the CMF. This is one of the main intended use cases for it.

For your usecase, one important thing to note is that the route base paths can be an array of paths. If you know the sites that will exist, you can simply configure base paths for all of them.

If they can be dynamically created, you will need some more work. You could check if the expression language can help you, or write a symfony request listener that comes very early and sets the right base path on the cmf_routing.phpcr_candidates_prefix service.

The sonata phpcr-odm admin was not really optimized for multisite use cases. However, with the help of the permission system, you should be able to control who may see what.

You could also write to the symfony-cmf-users mailing list. A couple of people did multisite projects with the CMF and might have additional ideas or inputs. And feel free to open pull requests or issues on the corresponding CMF repositories if you see things that could be improved.