0

那是我的控制器助手:

class Application_Controller_Helper_Test extends Zend_Controller_Action_Helper_Abstract
{
    public function preDispatch()
    {
        $this->_helper->redirector->gotoUrl('/index/index');
        // ...
    }

但是有错误,我无法修复:

调用gotoUrl()非对象的成员函数

4

2 回答 2

4

如果要从动作助手重定向,则必须从助手代理检索重定向助手。以下代码段将重定向到index/index.

$controller = $request->getControllerName();
$action = $request->getActionName();

// Prevent redirection loop
if ($controller.'/'.$action !== 'index/index') {
    $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
    $redirector->gotoSimpleAndExit('index', 'index', 'default');
}
于 2012-09-13T12:29:05.827 回答
0
$this->_redirector = $this->_helper->getHelper('Redirector');

$this->redirector('targetAction', 'targetController');

于 2012-09-13T12:53:11.683 回答