I'm trying to build an Symfony2 application, that have CMS features. I've got three entities (among others) which are : Page
, Category
, Post
(classic ones, huh ?)
I would like to have the following routing :
Page : /{slug} (slug is a Page entity field)
Category : /{slug} (slug is a Category entity field)
Post : /{slug} (slug is a Post entity field)
However, this will never work, because Symfony2 router, will match the first route that corresponds to the /{slug}
pattern.
I would like to know, what is the best pratice to handle these cases. I'm aware of Symfony CMF, but I do not want use this kind of massive tool (as it contains too many bundles which I'm not willing to use).
Thanks in advance for your answers
You will have to use a custom route loader to do this, check the cookbook article:
http://symfony.com/doc/current/cookbook/routing/custom_route_loader.html
The CMF project uses its own dynamic router which you could use without the full CMF stack also:
http://symfony.com/doc/current/cmf/bundles/routing/dynamic.html