public static function find403ByPid($intPid, array $arrOptions = array())
{
$t = static::$strTable;
$arrColumns = array("{$t}.pid=? AND {$t}.type='error_403'");
if (isset($arrOptions['ignoreFePreview']) || !BE_USER_LOGGED_IN) {
$time = \Date::floorToMinute();
$arrColumns[] = "({$t}.start='' OR {$t}.start<='{$time}') AND ({$t}.stop='' OR {$t}.stop>'" . ($time + 60) . "') AND {$t}.published='1'";
}
if (!isset($arrOptions['order'])) {
$arrOptions['order'] = "{$t}.sorting";
}
return static::findOneBy($arrColumns, $intPid, $arrOptions);
}
/** * Prepare the output * * @param PageModel|integer $objRootPage * * @return PageModel * * @throws AccessDeniedException * * @internal Do not call this method in your code. It will be made private in Contao 5.0. */ protected function prepare($objRootPage = null) { // Use the given root page object if available (thanks to Andreas Schempp) if ($objRootPage === null) { $objRootPage = $this->getRootPageFromUrl(); } else { $objRootPage = \PageModel::findPublishedById(is_integer($objRootPage) ? $objRootPage : $objRootPage->id); } // Look for a 403 page $obj403 = \PageModel::find403ByPid($objRootPage->id); // Die if there is no page at all if (null === $obj403) { throw new AccessDeniedException('Forbidden'); } // Forward to another page if ($obj403->autoforward && $obj403->jumpTo) { $objNextPage = \PageModel::findPublishedById($obj403->jumpTo); if (null === $objNextPage) { $this->log('Forward page ID "' . $obj403->jumpTo . '" does not exist', __METHOD__, TL_ERROR); throw new ForwardPageNotFoundException('Forward page not found'); } $this->redirect($objNextPage->getFrontendUrl(), $obj403->redirect == 'temporary' ? 302 : 301); } return $obj403; }