public function run()
{
$pageId = $this->getPageIdFromUrl();
$objRootPage = null;
// Load a website root page object if there is no page ID
if ($pageId === null) {
$objRootPage = $this->getRootPageFromUrl();
/** @var PageRoot $objHandler */
$objHandler = new $GLOBALS['TL_PTY']['root']();
$pageId = $objHandler->generate($objRootPage->id, true, true);
} elseif ($pageId === false) {
$this->User->authenticate();
throw new PageNotFoundException('Page not found: ' . \Environment::get('uri'));
}
$pageModel = \PageModel::findPublishedByIdOrAlias($pageId);
// Throw a 404 error if the page could not be found
if ($pageModel === null) {
throw new PageNotFoundException('Page not found: ' . \Environment::get('uri'));
}
return $this->renderPage($pageModel);
}