/** * Set a userland parameter * * Uses $key to set a userland parameter. If $key is an alias, the actual * key will be retrieved and used to set the parameter. * * @param mixed $key * @param mixed $value * @return EvHttp_Controller_Request_Http */ public function setParam($key, $value) { $key = null !== ($alias = $this->getAlias($key)) ? $alias : $key; parent::setParam($key, $value); return $this; }
/** * postDispatch() plugin hook -- check for exceptions and dispatch error * handler if necessary * * If the 'noErrorHandler' front controller flag has been set, * returns early. * * @param EvHttp_Controller_Request_Abstract $request * @return void */ public function postDispatch(EvHttp_Controller_Request_Abstract $request) { $frontController = EvHttp_Controller_Front::getInstance(); if ($frontController->getParam('noErrorHandler')) { return; } $response = $this->getResponse(); if ($this->_isInsideErrorHandlerLoop) { $exceptions = $response->getException(); if (count($exceptions) > $this->_exceptionCountAtFirstEncounter) { // Exception thrown by error handler; tell the front controller to throw it $frontController->throwExceptions(true); throw array_pop($exceptions); } } // check for an exception AND allow the error handler controller the option to forward if ($response->isException() && !$this->_isInsideErrorHandlerLoop) { $this->_isInsideErrorHandlerLoop = true; // Get exception information $error = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); $exceptions = $response->getException(); $exception = $exceptions[0]; $exceptionType = get_class($exception); $error->exception = $exception; switch ($exceptionType) { case 'EvHttp_Controller_Dispatcher_Exception': $error->type = self::EXCEPTION_NO_CONTROLLER; break; case 'EvHttp_Controller_Action_Exception': if (404 == $exception->getCode()) { $error->type = self::EXCEPTION_NO_ACTION; } else { $error->type = self::EXCEPTION_OTHER; } break; default: $error->type = self::EXCEPTION_OTHER; break; } // Keep a copy of the original request $error->request = clone $request; // get a count of the number of exceptions encountered $this->_exceptionCountAtFirstEncounter = count($exceptions); // Forward to the error handler $request->setParam('error_handler', $error)->setModuleName($this->getErrorHandlerModule())->setControllerName($this->getErrorHandlerController())->setActionName($this->getErrorHandlerAction())->setDispatched(false); } }