Page 1 of 1

Override Zend\Http\Request

Posted: Thu Mar 19, 2015 7:10 pm
by DaveTheAve
I have tried several ways to acheive this and each time I receive the error
Fatal error: Uncaught exception 'Zend\View\Exception\RuntimeException' with message 'No base path provided' in \vendor\zendframework\zendframework\library\Zend\View\Helper\BasePath.php on line 38
First I tried:

Code: Select all

    'service_manager' => array(
        'invokables' => array(
            'request' => 'Application\Http\Request',
        ),
    ),
That told me I could not override the class. So I tried this:

Code: Select all

    public function onBootstrap(MvcEvent $e)
    {
        $serviceManager        = $e->getApplication()->getServiceManager();
        $serviceManager->setAllowOverride(true)
            ->setInvokableClass('request', 'Application\Http\Request')
            ->setAllowOverride(false);
    }
The whole reason I'm doing this is because I have the need for "per-instance variables", variables that only last for that single HTTP GET execution. Essentially, I wish to have an access log built into my system but I do not wish for it to log EVERY AJAX query yet I do need SOME AJAX queries logged. For instance, I don't want calls to AjaxController\getCompanyListingAction() to be logged but I would like AjaxController\createNewCompanyAction() to be logged.

Would anyone please be kind enough to point me in the right direction? :D

I have already extended Zend\Http\Request with "getInstanceParam()" and "setInstanceParam()" functions and just wish to plug-it-in but I am open to alternative options.