public function renderPage(Page $page) { $rendered = false; $cacheId = 'page-' . static::$DI['Request']->getRoute(); if (empty($page->nocache)) { $rendered = static::$DI['Cache\\PageCache']->get($cacheId); } if (false === $rendered) { $content = new \stdClass(); $content->string = ''; try { if (empty($page->layout)) { $content = $page->getSegment(0); $content->string = Hook::trigger(Hook::FILTER, 'renderContent', $content->string, $page->getData()); } else { $content->string = Hook::trigger(Hook::FILTER, 'renderLayout', $page); } } catch (\Exception $e) { $page->setError($e); $content->string = Hook::trigger(Hook::FILTER, 'renderLayout', $page); } if (empty($page->nocache)) { static::$DI['Cache\\PageCache']->set($cacheId, $content->string); } $rendered = $content->string; } $response = new Http\Response($rendered); $response->setStatus($page->getStatusCode()); $response->setHeader('Content-Type', $page->content_type); return $response; }