public function hook_indexContent(TypoScriptFrontendController $page)
    {
        $this->logger = GeneralUtility::makeInstance(SolrLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);

        $this->page = $page;
        $configuration = Util::getSolrConfiguration();

        $logPageIndexed = $configuration->getLoggingIndexingPageIndexed();
        if (!$this->page->config['config']['index_enable']) {
            if ($logPageIndexed) {
                $this->logger->log(
                    SolrLogManager::ERROR,
                    'Indexing is disabled. Set config.index_enable = 1 .'
                );
            }
            return;
        }

        try {
            $indexQueueItem = $this->getIndexQueueItem();
            if (is_null($indexQueueItem)) {
                throw new \UnexpectedValueException('Can not get index queue item', 1482162337);
            }

            $solrConnection = $this->getSolrConnection($indexQueueItem);

            /** @var $indexer Typo3PageIndexer */
            $indexer = GeneralUtility::makeInstance(Typo3PageIndexer::class, /** @scrutinizer ignore-type */ $page);
            $indexer->setSolrConnection($solrConnection);
            $indexer->setPageAccessRootline($this->getAccessRootline());
            $indexer->setPageUrl($this->generatePageUrl());
            $indexer->setMountPointParameter($GLOBALS['TSFE']->MP);
            $indexer->setIndexQueueItem($indexQueueItem);

            $this->responseData['pageIndexed'] = (int)$indexer->indexPage();
            $this->responseData['originalPageDocument'] = (array)$indexer->getPageSolrDocument();
            $this->responseData['solrConnection'] = [
                'rootPage' => $indexQueueItem->getRootPageUid(),
                'sys_language_uid' => $GLOBALS['TSFE']->sys_language_uid,
                'solr' => (string)$solrConnection->getNode('write')
            ];

            $documentsSentToSolr = $indexer->getDocumentsSentToSolr();
            foreach ($documentsSentToSolr as $document) {
                $this->responseData['documentsSentToSolr'][] = (array)$document;
            }
        } catch (\Exception $e) {
            if ($configuration->getLoggingExceptions()) {
                $this->logger->log(
                    SolrLogManager::ERROR,
                    'Exception while trying to index page ' . $page->id,
                    [
                        $e->__toString()
                    ]
                );
            }
        }

        if ($logPageIndexed) {
            $success = $this->responseData['pageIndexed'] ? 'Success' : 'Failed';
            $severity = $this->responseData['pageIndexed'] ? SolrLogManager::NOTICE : SolrLogManager::ERROR;

            $this->logger->log(
                $severity,
                'Page indexed: ' . $success,
                $this->responseData
            );
        }
    }
public function hook_indexContent(TypoScriptFrontendController $page)
    {
        $this->logger = GeneralUtility::makeInstance(SolrLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);

        $this->page = $page;
        $configuration = Util::getSolrConfiguration();

        $logPageIndexed = $configuration->getLoggingIndexingPageIndexed();
        if (!$this->page->config['config']['index_enable']) {
            if ($logPageIndexed) {
                $this->logger->log(
                    SolrLogManager::ERROR,
                    'Indexing is disabled. Set config.index_enable = 1 .'
                );
            }
            return;
        }

        try {
            $indexQueueItem = $this->getIndexQueueItem();
            if (is_null($indexQueueItem)) {
                throw new \UnexpectedValueException('Can not get index queue item', 1482162337);
            }

            $solrConnection = $this->getSolrConnection($indexQueueItem);

            /** @var $indexer Typo3PageIndexer */
            $indexer = GeneralUtility::makeInstance(Typo3PageIndexer::class, /** @scrutinizer ignore-type */ $page);
            $indexer->setSolrConnection($solrConnection);
            $indexer->setPageAccessRootline($this->getAccessRootline());
            $indexer->setPageUrl($this->generatePageUrl());
            $indexer->setMountPointParameter($GLOBALS['TSFE']->MP);
            $indexer->setIndexQueueItem($indexQueueItem);

            $this->responseData['pageIndexed'] = (int)$indexer->indexPage();
            $this->responseData['originalPageDocument'] = (array)$indexer->getPageSolrDocument();
            $this->responseData['solrConnection'] = [
                'rootPage' => $indexQueueItem->getRootPageUid(),
                'sys_language_uid' => $GLOBALS['TSFE']->sys_language_uid,
                'solr' => (string)$solrConnection->getNode('write')
            ];

            $documentsSentToSolr = $indexer->getDocumentsSentToSolr();
            foreach ($documentsSentToSolr as $document) {
                $this->responseData['documentsSentToSolr'][] = (array)$document;
            }
        } catch (\Exception $e) {
            if ($configuration->getLoggingExceptions()) {
                $this->logger->log(
                    SolrLogManager::ERROR,
                    'Exception while trying to index page ' . $page->id,
                    [
                        $e->__toString()
                    ]
                );
            }
        }

        if ($logPageIndexed) {
            $success = $this->responseData['pageIndexed'] ? 'Success' : 'Failed';
            $severity = $this->responseData['pageIndexed'] ? SolrLogManager::NOTICE : SolrLogManager::ERROR;

            $this->logger->log(
                $severity,
                'Page indexed: ' . $success,
                $this->responseData
            );
        }
    }
public function hook_indexContent ( TypoScriptFrontendController $ page ) { $ this -> logger = GeneralUtility :: makeInstance ( SolrLogManager :: class , /** @scrutinizer ignore-type */ __CLASS__ ) ; $ this -> page = $ page ; $ configuration = Util :: getSolrConfiguration ( ) ; $ logPageIndexed = $ configuration -> getLoggingIndexingPageIndexed ( ) ; if ( ! $ this -> page -> config [ 'config' ] [ 'index_enable' ] ) { if ( $ logPageIndexed ) { $ this -> logger -> log ( SolrLogManager :: ERROR , 'Indexing is disabled. Set config.index_enable = 1 .' ) ; } return ; } try { $ indexQueueItem = $ this -> getIndexQueueItem ( ) ; if ( is_null ( $ indexQueueItem ) ) { throw new \ UnexpectedValueException ( 'Can not get index queue item' , 1482162337 ) ; } $ solrConnection = $ this -> getSolrConnection ( $ indexQueueItem ) ; /** @var $indexer Typo3PageIndexer */ $ indexer = GeneralUtility :: makeInstance ( Typo3PageIndexer :: class , /** @scrutinizer ignore-type */ $ page ) ; $ indexer -> setSolrConnection ( $ solrConnection ) ; $ indexer -> setPageAccessRootline ( $ this -> getAccessRootline ( ) ) ; $ indexer -> setPageUrl ( $ this -> generatePageUrl ( ) ) ; $ indexer -> setMountPointParameter ( $ GLOBALS [ 'TSFE' ] -> MP ) ; $ indexer -> setIndexQueueItem ( $ indexQueueItem ) ; $ this -> responseData [ 'pageIndexed' ] = ( int ) $ indexer -> indexPage ( ) ; $ this -> responseData [ 'originalPageDocument' ] = ( array ) $ indexer -> getPageSolrDocument ( ) ; $ this -> responseData [ 'solrConnection' ] = [ 'rootPage' => $ indexQueueItem -> getRootPageUid ( ) , 'sys_language_uid' => $ GLOBALS [ 'TSFE' ] -> sys_language_uid , 'solr' => ( string ) $ solrConnection -> getNode ( 'write' ) ] ; $ documentsSentToSolr = $ indexer -> getDocumentsSentToSolr ( ) ; foreach ( $ documentsSentToSolr as $ document ) { $ this -> responseData [ 'documentsSentToSolr' ] [ ] = ( array ) $ document ; } } catch ( \ Exception $ e ) { if ( $ configuration -> getLoggingExceptions ( ) ) { $ this -> logger -> log ( SolrLogManager :: ERROR , 'Exception while trying to index page ' . $ page -> id , [ $ e -> __toString ( ) ] ) ; } } if ( $ logPageIndexed ) { $ success = $ this -> responseData [ 'pageIndexed' ] ? 'Success' : 'Failed' ; $ severity = $ this -> responseData [ 'pageIndexed' ] ? SolrLogManager :: NOTICE : SolrLogManager :: ERROR ; $ this -> logger -> log ( $ severity , 'Page indexed: ' . $ success , $ this -> responseData ) ; } }
Handles the indexing of the page content during post processing of a
generated page.

@param TypoScriptFrontendController $page TypoScript frontend
Handles the indexing of the page content during post processing of a generated page .