Is it possible to add custom Symfony2 route global variables like _format and _locale?
In my Symfony2 project, I have a news site with posts. These posts can be published in different regions. The current scope (user selection) must be part of the url. So the urls should look like this:
/mag => main news site, no region selection
/mag/region1/ => posts for region 1
/mag/region2/ => ...
/mag/region1/my-news-post-slug => detail view of one post
In the news posts I used the Sonata News Sonata .
Now my question is, how do I add a region to the routing system without changing every controller and package template I use? When I just add it to my routing config like
magazin:
resource: '@SonataNewsBundle/Resources/config/routing/news.xml'
prefix: /mag/{region}
I am getting errors because this parameter is not set when generating the route in the controllers and templates of the newsletter (and others). I need something like route variables {_format}
or {_locale}
that are obviously already added by the routing component. Can such global values be added?
source to share