/** * @param string $uri * * @return mixed */ public function process($uri) { $this->page = Page::findByUri($uri); if (!$this->page) { $url = URL::findByLocation($uri); // The URL isn't in use or // The URL is in use and has a page - the page must not be visible to the current user // // 404. if (!$url || !$url->getPage()->isVisible()) { throw new NotFoundHttpException(); } // The url is in use but doesn't have a page. // The page must have been deleted. // // 410. throw new GoneHttpException(); } if (Editor::isDisabled() && !$this->page->isVisible()) { throw new NotFoundHttpException(); } if (!$this->page->url()->is($uri)) { return redirect((string) $this->page->url(), 301); } }