Search code examples
symfonyroutessymfony-cmf

Symfony CMF uri property vs route node


I was wondering what would be the best solution to handle routes in a CMS system. Currently I am using an URI property on my documents that I convert (through a RouteProvider) to a symfony route object. This seems for me the most simple and elegant solution, but is it?

When should you choose an URI property on a document for routes and when should you use specific route nodes that map to documents? What are the benefits etc.

By default CMF uses seperate route nodes/documents to map a route to a content document.

Thanks!


Solution

  • The Symfony CMF can use both ways. The CMF provides 2 seperate bundles, ContentBundle and RoutingBundle. This has some reasons, one of which is that you are able to use only the RoutingBundle or only the ContentBundle, they are no longer tied together.

    The Symfony CMF also provides a SimpleCmsBundle. This bundle demostrates how you can make one document for both things. That's done by creating a Page document which extends both Content and Route documents.

    The main advantage of using 2 documents is that you can have multiple routes pointing to the same content. For instance, this makes it very easy to have i18n routes on a multi-language site. You just create routes like /hello, /bonjour and /gütentag and point them to the same Content document (which, on his part, has multiple languages of the content).