2010-08-23 69 views
1

如何扩展Zend_Controller_Request_Http,让应用程序知道My_Controller_Request_Http?如何扩展Zend_Controller_Request_Http

解决方案

这是我如何得到它的工作如下戈登三分球。

Firts保存以下文件资料库:我的/控制器/申请/ Http.php

<?php 

class My_Controller_Request_Http extends Zend_Controller_Request_Http { 

    /* Add all your custom functions here */ 

} 

在引导类添加以下。

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 */ 
} 

回答

2

http://framework.zend.com/manual/en/zend.controller.front.html

了setRequest()Request()方法让你指定的请求类或对象在分发过程中使用,并获取当前对象。在设置请求对象时,您可以传入一个请求类名,在这种情况下,该方法将加载类文件并对其进行实例化。

API

Zend_Controller_Front setRequest (string|Zend_Controller_Request_Abstract $request) 

类也有可能(不知道),通过传递正确的价值观Zend_Application_Resource_Frontcontroller

子类Request对象从配置设置在

解释
+1

谢谢戈登! – Phliplip 2010-08-23 12:26:58