$r = $this->_front->getRouter();
$r->addRoute('moo', $route);
2008/12/4 Andrew Collington <php@amnuts.com>:
> Hi there,
>
> I am trying to have my routes set via a plugin, but even though it seems
> like the front controller is having the router updated and assigning the
> router is in the routeStartup method of my plugin, my routes don't seem to
> work.
>
> My plugin looks like:
>
>
> class Broadcast_Controller_Plugin_Routes extends
> Zend_Controller_Plugin_Abstract
> {
> /**
> * Called before Zend_Controller_Front begins evaluating the
> * request against its routes.
> *
> * @param Zend_Controller_Request_Abstract $request
> * @return void
> */
> public function routeStartup(Zend_Controller_Request_Abstract $request)
> {
> $router = new Zend_Controller_Router_Rewrite();
> $router->addRoute('login',
> new Zend_Controller_Router_Route_Static('login',
> array(
> 'module' => 'default',
> 'controller' => 'index',
> 'action' => 'index'
> )
> )
> );
> $router->addRoute('logout',
> new Zend_Controller_Router_Route_Static('logout',
> array(
> 'module' => 'default',
> 'controller' => 'index',
> 'action' => 'logout'
> )
> )
> );
> Zend_Controller_Front::getInstance()->setRouter($router);
> }
> }
>
>
> I have other routes in there but limited it to only two for brevity.
>
> Should this work? Am I just doing something stupidly wrong? Any advice is
> appreciated!
>
> Many thanks,
>
> Andy
>
>
--
----------------------------------------------------------------------
[MuTe]
----------------------------------------------------------------------
没有评论:
发表评论