find403ByPid() public static method

Find an error 403 page by its parent ID
public static find403ByPid ( integer $intPid, array $arrOptions = [] ) : PageModel | null
$intPid integer The parent page's ID
$arrOptions array An optional options array
return PageModel | null The model or null if there is no 403 page
Example #1
0
 /**
  * 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;
 }