在ZF控制器的操作中组装URL时出现意外的值

时间:2012-09-17 14:27:58

标签: php zend-framework

我为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()将始终返回意外值。

我做错了什么?

0 个答案:

没有答案