find404ByPid() public static method

Find an error 404 page by its parent ID
public static find404ByPid ( 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 404 page
 /**
  * Prepare the output
  *
  * @return \PageModel
  *
  * @internal
  */
 protected function prepare()
 {
     // Check the search index (see #3761)
     \Search::removeEntry(\Environment::get('relativeRequest'));
     // Find the matching root page
     $objRootPage = $this->getRootPageFromUrl();
     // Forward if the language should be but is not set (see #4028)
     if (\Config::get('addLanguageToUrl')) {
         // Get the request string without the script name
         $strRequest = \Environment::get('relativeRequest');
         // Only redirect if there is no language fragment (see #4669)
         if ($strRequest != '' && !preg_match('@^[a-z]{2}(\\-[A-Z]{2})?/@', $strRequest)) {
             // Handle language fragments without trailing slash (see #7666)
             if (preg_match('@^[a-z]{2}(\\-[A-Z]{2})?$@', $strRequest)) {
                 $this->redirect(\Environment::get('request') . '/', 301);
             } else {
                 if ($strRequest == \Environment::get('request')) {
                     $strRequest = $objRootPage->language . '/' . $strRequest;
                 } else {
                     $strRequest = \Environment::get('script') . '/' . $objRootPage->language . '/' . $strRequest;
                 }
                 $this->redirect($strRequest, 301);
             }
         }
     }
     // Look for a 404 page
     $obj404 = \PageModel::find404ByPid($objRootPage->id);
     // Die if there is no page at all
     if (null === $obj404) {
         throw new PageNotFoundException('Page not found');
     }
     // Forward to another page
     if ($obj404->autoforward && $obj404->jumpTo) {
         $objNextPage = \PageModel::findPublishedById($obj404->jumpTo);
         if (null === $objNextPage) {
             $this->log('Forward page ID "' . $obj404->jumpTo . '" does not exist', __METHOD__, TL_ERROR);
             throw new ForwardPageNotFoundException('Forward page not found');
         }
         $this->redirect($this->generateFrontendUrl($objNextPage->row(), null, $objRootPage->language), $obj404->redirect == 'temporary' ? 302 : 301);
     }
     return $obj404;
 }