如何扩展Zend_Controller_Request_Http,让应用程序知道My_Controller_Request_Http ??
解决方案
这就是我按照戈登斯的指示工作的方式。
Firts将以下文件保存到您的库中:My / Controller / Request / Http.php
<?php
class My_Controller_Request_Http extends Zend_Controller_Request_Http {
/* Add all your custom functions here */
}
在bootstrap类中,我添加了以下内容。
function _initApplication ()
{
/* Doing some other stuff here */
$this->bootstrap('frontcontroller');
$front = $this->getResource('frontcontroller');
$front->setRequest('My_Controller_Request_Http');
/* Registering some plugins here, not relevant */
}
答案 0 :(得分:2)
来自http://framework.zend.com/manual/en/zend.controller.front.html
setRequest()和getRequest()允许您指定在调度过程中使用的请求类或对象,并检索当前对象。设置请求对象时,您可以传入请求类名,在这种情况下,该方法将加载类文件并实例化它。
来自API:
Zend_Controller_Front setRequest (string|Zend_Controller_Request_Abstract $request)
通过将正确的值传递给Zend_Application_Resource_Frontcontroller
在
中解释了对Request对象进行子类化