views:

69

answers:

1

With the new Zend_Application/Zend_Application_Bootstrap classes I'm confused as to where I should be applying my custom routes. For example, at the moment I have one route:

protected function _initRouter() {
    $router = new Zend_Controller_Router_Rewrite;
    $route = new Zend_Controller_Router_Route('news/:id', 
        array('controller' => 'news', 'action' => 'view'));
    $router->addRoute('postArchive', $route);           
}

This method is in my Zend_Application_Bootstrap_Bootstrap and is definitely run. The route is also applied in $router.

As I see it I could be doing two things wrong - either the wrong place to add these routes, or not adding to the correct router. Can anyone point me in the right direction with this?

+1  A: 

Looks like you are not passing the router to the front controller:

protected function _initRouter() 
{
    $this->bootstrap('frontController');
    $front = Zend_Controller_Front::getInstance(); // from singleton, for example
    $router = $front->getRouter();
    $route = new Zend_Controller_Router_Route('news/:id', 
        array('controller' => 'news', 'action' => 'view'));
    $router->addRoute('postArchive', $route);  

    return $router;
}
takeshin