Paladyn wrote > I`m a bit confused in this one. > Of course I started from setting :lang in all models routes. > Should I build event dispatch in every Module separately or there is a way > to make it global (in bootstrap?)? How to get right route if some of > parameters are set in some controllers. And how to get route which was set > before clicking on flag. > I feel this is very simple but I`m just a bit dumpass here. > > Btw. thanks luk for all help, all answered questions in threads I make > here!
Yes you can do it in one Module globally onBootstrap. To make it global per controller attach it to every AbstractController on dispatch, like: public function onBootstrap($e) { $sharedEvents = $e->getApplication()->getEventManager()->getSharedManager(); $sharedEvents->attach('Zend\Mvc\Controller\AbstractActionController', 'dispatch', function($e) { $controller = $e->getTarget(); $matchedRoute = $controller->getEvent()->getRouteMatch(); $routeMatchLang = $matchedRoute->getParam('lang'); if (in_array($routeMatchLang, array('de','en'))) { // set locale here } // redirect back return $controller->redirect()->toRoute('lastRoute'); }); } ----- Cheers, -- Luke Mierzwa -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/Setting-global-value-tp4657568p4657642.html Sent from the Zend Framework mailing list archive at Nabble.com. -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com