protected function onError(Exception $e) { $response = $this->getResponse(); $response->clear(); if ($e instanceof UnknownActionException || $e instanceof ControllerConstructionException) { $response->setStatus(404); $viewPath = '/shared/404.php'; } else { $response->setStatus(500); $viewPath = '/shared/500.php'; } $view = new View($this->getViewPath() . $viewPath); $context = new RenderingContext($view, $this->getRequest(), $this->getRoutes(), null, new ErrorModel($e, $this->debugEnabled)); $view->render($context); }
public function render(RenderingContext $context) { if (!is_file($this->path) || !is_readable($this->path)) { throw new RuntimeException("The path \"{$this->path}\" is not a file or is not readable"); } $html = new HtmlHelper($context); $model = $context->model; ob_start(); require $this->path; $extraBuffer = ob_get_clean(); if ($this->currentSection) { $this->sections[$this->currentSection] = $extraBuffer; } else { echo $extraBuffer; } $this->currentSection = null; if ($this->parent) { $this->parent->render($context); } }