Contao\Frontend::indexPageIfApplicable PHP Метод

indexPageIfApplicable() публичный статический Метод

Index a page if applicable
public static indexPageIfApplicable ( Response $objResponse )
$objResponse Symfony\Component\HttpFoundation\Response
    public static function indexPageIfApplicable(Response $objResponse)
    {
        global $objPage;
        if ($objPage === null) {
            return;
        }
        // Index page if searching is allowed and there is no back end user
        if (\Config::get('enableSearch') && $objPage->type == 'regular' && !BE_USER_LOGGED_IN && !$objPage->noSearch) {
            // Index protected pages if enabled
            if (\Config::get('indexProtected') || !FE_USER_LOGGED_IN && !$objPage->protected) {
                $blnIndex = true;
                // Do not index the page if certain parameters are set
                foreach (array_keys($_GET) as $key) {
                    if (in_array($key, $GLOBALS['TL_NOINDEX_KEYS']) || strncmp($key, 'page_', 5) === 0) {
                        $blnIndex = false;
                        break;
                    }
                }
                if ($blnIndex) {
                    $arrData = array('url' => \Environment::get('base') . \Environment::get('relativeRequest'), 'content' => $objResponse->getContent(), 'title' => $objPage->pageTitle ?: $objPage->title, 'protected' => $objPage->protected ? '1' : '', 'groups' => $objPage->groups, 'pid' => $objPage->id, 'language' => $objPage->language);
                    \Search::indexPage($arrData);
                }
            }
        }
    }

Usage Example

 /**
  * Forwards the request to the Frontend class if there is a page object.
  *
  * @param PostResponseEvent $event The event object
  */
 public function onKernelTerminate(PostResponseEvent $event)
 {
     if (!$this->framework->isInitialized()) {
         return;
     }
     Frontend::indexPageIfApplicable($event->getResponse());
 }