/** * The request router looks at the URI path, tries to load it from /assets, * then tries to route the request through the Router if it's a model. * If it's not a model, the PageEngine tries to render the template file. */ function routeRequest() { $path = getPath(); if (!$path) { return PageEngine::renderPage('index'); } if (File::find("assets/{$path}")) { File::render("assets/{$path}"); } try { $router = new Router(); return $router->route($path); } catch (ModelExistenceException $e) { return PageEngine::renderPage($path); } }
/** * The default response method, outputs a full page. */ private function output_full() { if ($this->doRedirect()) { header("Location: http://{$_SERVER['SERVER_NAME']}" . getLink($this->controller->redirect)); //Just in case something goes horribly wrong, we'll add this fallback: echo "You should have been redirected <a href=\"" . getLink($this->controller->redirect) . "\">here</a>."; return; } try { $out = PageEngine::renderPage("{$this->model}/{$this->command}", array('result' => $this->result, 'errors' => $this->controller->errors)); } catch (Exception $e) { $this->exception = $e; } if ($this->exception) { $out = PageEngine::renderPage("error", array('result' => $this->exception)); } return $out; }