1

我已经命名了路线admin/login/

'adminLogin' => new Zend_Controller_Router_Route(
        'admin/login/',
        array('controller' => 'index', 'action' => 'login', 'module' => 'admin')
),

现在让我们看一下我调用路由器assemble()函数的控制器:

class Admin_Controller_Index extends Zend_Controller_Action
{

    public function loginAction() {

        echo Zend_Controller_Front::getInstance()->getRouter()->assemble(
            array(
                'controller' => 'index',
                'action' => 'authentificate',
                'module' => 'admin'
            )
        );
        // will output /admin/login
        //any other plays with assemble() function will always return /admin/login
        //Why???
        exit;

    }

    public function authenitifcateAction() {
        echo Zend_Controller_Front::getInstance()->getRouter()->assemble(
            array(
                'controller' => 'index',
                'action' => 'authentificate',
                'module' => 'admin'
            )
        );
        //will output /admin/index/authentificate as expected
        //any other plays with assemble() function will aslo return expected values
        exit;
    }

}

因此,assemble()如果在具有命名路由的控制器操作中调用,将始终返回意外值。

我究竟做错了什么?

4

0 回答 0