/** * initialize the current page */ protected function initializeCurrentPage() { $pageId = $this->router->getCurrentUrl(); Event::triggerEvent('request_uri', ['uri' => $pageId]); $page = $this->pageRepository->findByPath($pageId); $found = $page instanceof Page; if ($found && $pageId !== $page->getPageId()) { $url = $this->router->urlForPage($page->getPageId()); $this->response->redirect($url, 301); } if (!$found) { $this->response->setStatusCode(404); $page = $this->pageRepository->findByPath('404'); Event::triggerEvent('after_404'); } Event::triggerEvent('after_resolve_page', ['pageId' => $pageId, 'page' => &$page]); $this->page = $page; }