views:

21

answers:

1

Hi all,

How do I extend the Zend_Controller_Request_Http, and let the application know of My_Controller_Request_Http ??

Solution

This is how i got it working following Gordons pointers.

Firts save the following file your library: My/Controller/Request/Http.php

<?php

class My_Controller_Request_Http extends Zend_Controller_Request_Http {

    /* Add all your custom functions here */

}

In the bootstrap class i added the following.

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  A: 

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

setRequest() and getRequest() let you specify the request class or object to use during the dispatch process and to retrieve the current object. When setting the request object, you may pass in a request class name, in which case the method will load the class file and instantiate it.

From API:

Zend_Controller_Front  setRequest  (string|Zend_Controller_Request_Abstract $request) 

The class can also likely (not sure) be set from a config by passing the correct values to Zend_Application_Resource_Frontcontroller

Subclassing the Request object is explained in

Gordon
Thank's Gordon!
Phliplip