views:

11

answers:

1

Hello, can't figure out, why does key lang disappears between language plugin and matched custom route. I'm calling registry from inside model, which is requested inside custome route.

http://pastie.org/1088574

 Message: No entry is registered for key 'lang'
Stack trace:

#0 C:\xampp\xampp\htdocs\chat\application\models\Getcategories.php(15): Zend_Registry::get('lang')
#1 C:\xampp\xampp\htdocs\chat\library\Routes\Categories.php(64): Getcategories->__construct()
#2 C:\xampp\xampp\htdocs\chat\library\Zend\Controller\Router\Rewrite.php(398): Routes_Categories->match('/ru/woman-searc...')
#3 C:\xampp\xampp\htdocs\chat\library\Zend\Controller\Front.php(911): Zend_Controller_Router_Rewrite->route(Object(Zend_Controller_Request_Http))
#4 C:\xampp\xampp\htdocs\chat\library\Zend\Controller\Front.php(212): Zend_Controller_Front->dispatch()
#5 C:\xampp\xampp\htdocs\chat\application\Bootstrap.php(65): Zend_Controller_Front::run('C:\xampp\xampp\...')
#6 C:\xampp\xampp\htdocs\chat\public\index.php(34): Bootstrap->run(Array)
#7 {main}  

I have checked inside language plugin, it registers lang key fine.

Zend_Registry::get('lang') inside route throws exception as well.

+2  A: 

Make sure the Registry-Key is set in Plugins_LangSelector::routeStartup() so it will be registered before processing the routes.

From the ZF-Manual: Plugins

routeStartup() is called before Zend_Controller_Front calls on the router to evaluate the request against the registered routes.

If you set the key in routeShutdown(), preDispatch(), postDispatch() or dispatchLoopShutdown() it is to late.

Benjamin Cremer
Mate! Thanks you a lot! I didn't knew that preDispatch doesn't do it before matching routes. :\Everything works now.
Beck