symfony - Is it possible to add custom global Symfony2 route variables like _format and _locale? -


in symfony2 project, have news site has posts. posts can published in different regions. current region (user choice) has part of url. urls should this:

/mag => main news site, no region selection /mag/region1/ => posts region 1 /mag/region2/ => ... /mag/region1/my-news-post-slug => detail view of 1 post 

for news posts, used sonata news bundle.

now question is, how add region choice of user route system without having change each controller , template of bundles use? when add routing config

magazin:     resource:   '@sonatanewsbundle/resources/config/routing/news.xml'     prefix:     /mag/{region} 

i errors because parameter not set when generating route in controllers , templates of news bundle (and others). need {_format} or {_locale} route variables added routing component obviously. possible add "global" values that?

take @ how symfony locale.

https://github.com/symfony/symfony/blob/2.8/src/symfony/component/httpkernel/eventlistener/localelistener.php

they use event listener capture locale request parameters , add router's context parameters.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -