开发者

Zend router config xml, shortcut?

开发者 https://www.devze.com 2023-03-01 07:15 出处:网络
I have an xml like this <configdata> <routes> <home type=\"Zend_Controller_Router_Route\">

I have an xml like this

<configdata>
    <routes>
        <home type="Zend_Controller_Router_Route">
            <route>home</route>
            <defaults>
                <controller>index</controller>
                <acti开发者_如何学Goon>index</action>
            </defaults>
        </home>
    </routes>
</configdata>

Now this works but I'd like to give each rout a shortcut like you would add in bootstrap like this..

$router->addRoute('shortcut_key',$route);

How can I do this in the config xml?


On your bootsrap.php...

protected function _initRoutes()
 {
  $routefile = new Zend_Config_Xml(APPLICATION_PATH.'/routes.xml');
  $router = Zend_Controller_Front::getInstance()->getRouter();
  $router->addConfig($routefile);
  return $router;
 }

where routes.xml file is the xml file containing all routes and it must be inside your application folder

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号