如何从引导文件内部获取请求对象?
我可以尝试这种方法,但不能工作.
$request= new Zend_Controller_Request_Http(); $request = Zend_Controller_FrontController::getInstance()->getRequest();
如果你真的想要,你可以实现这个呼叫:
public function _initRequest() { $this->bootstrap('frontController'); $front = $this->getResource('frontController'); $front->setRequest(new Zend_Controller_Request_Http()); $request = $front->getRequest(); }
但是,应该避免这种情况,因为在调用前端控制器(例如模块,控制器或动作名称)之后,Response对象所需的大部分数据都将可用.
存储在Response对象中的其他变量从全局数组(例如$_SERVER,$_POST或$_GET)中提取,您可以直接在引导中直接读取.
但是很可能你想在front controller plugin中使用Response对象:
class Your_Controller_Plugin_PluginName extends Zend_Controller_Plugin_Abstract { public function preDispatch(Zend_Controller_Request_Abstract $request) { // do anything with the $request here } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。