zend-framework - 在前端 Controller 插件 Zend 中重定向

标签 zend-framework redirect plugins request response

我正在尝试将我的重定向(基于身份验证和其他各种状态)集中到一个前端 Controller 插件中。到目前为止,我已经尝试过:

    $this->setRequest(new Zend_Controller_Request_Http('my_url'));

在插件的各个点(即从 routeStartup 到 dispatchLoopShutdown)以及:
    $this->setResponse(new Zend_Controller_Response_Http('my_url'));

任何人都可以为此提供一些帮助,或者为我指明教程的方向?

最佳答案

如果您希望在用户未登录的情况下进行重定向,dispatchLoopStartup() 的第一个参数是请求对象的句柄。

public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
{
    if(!Zend_Auth::getInstance()->hasIdentity())
    {
        $request->setControllerName('auth');
        $request->setActionName('login');
        // Set the module if you need to as well.
    }
}

关于zend-framework - 在前端 Controller 插件 Zend 中重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2357732/

相关文章:

php - SOAP 错误 : Parsing WSDL: Couldn't load from 'xxx/?wsdl' : Premature end of data in tag html line 1

php - 基于 Zend 框架构建的 CMS

internet-explorer - 如何从我的程序中列出 Internet Explorer 使用的插件 (BHO)?

javascript - BuzzFeed 如何进行移动重定向?

Linux I/O 重定向

php - 如何在 Shopware 6 插件 ZIP 中包含重叠的 Composer 依赖项?

jquery - 我如何使分辨率正常

php - Zend Framework session 命名空间调试 print_r 或等价物

php - 相互了解的对象

.net - 如何阻止我的 Azure 网站将所有 HTTP 流量自动重定向到 HTTPS?