/** * Runs the error controller action for the specified HTTP error code. * * @param int $errorCode The error code * * @return void */ protected function runErrorAction($errorCode) { $controllerName = $this->config->get('system.errorController', self::DEFAULT_ERROR_CONTROLLER_NAME); try { try { $controller = $this->diContainer->getController($controllerName, $this->request, $this->response); } catch (ControllerException $exception) { // No such controller, fall back to built in default $controller = $this->diContainer->getDefaultErrorController($this->request, $this->response); $controllerName = self::DEFAULT_ERROR_CONTROLLER_NAME; } } catch (\Exception $e) { $this->dispatchedController = $controllerName; $this->dispatchedAction = 500; throw $e; } $this->dispatchedController = $controllerName; $this->dispatchedAction = $errorCode; $this->raiseEventIfNotRaisedYet(Event::TYPE_APPLICATION_BEFORE_CONTROLLER_RUN); $controller->run($errorCode); $this->raiseEventIfNotRaisedYet(Event::TYPE_APPLICATION_AFTER_CONTROLLER_RUN); $this->response->render(); $this->raiseEventIfNotRaisedYet(Event::TYPE_APPLICATION_BEFORE_OUTPUT_SEND); $this->response->send(); $this->raiseEventIfNotRaisedYet(Event::TYPE_APPLICATION_AFTER_OUTPUT_SEND); }
public function testDefaultErrorController() { $sc = new SystemContainer(); $controller = $sc->getDefaultErrorController(new \YapepBase\Request\HttpRequest(array(), array(), array(), array('REQUEST_URI' => '/'), array(), array(), array()), new \YapepBase\Response\HttpResponse(new OutputMock())); $this->assertInstanceOf('\\YapepBase\\Controller\\DefaultErrorController', $controller, 'The retrieved error controller is of invalid type'); }