protected function getConfiguredSolrConnectionByRootPage(array $rootPage, $languageId)
    {
        $connection = [];

        $languageId = (int)$languageId;
        GeneralUtility::_GETset($languageId, 'L');
        $connectionKey = $rootPage['uid'] . '|' . $languageId;

        $pageSelect = GeneralUtility::makeInstance(PageRepository::class);
        $rootLine = $pageSelect->getRootLine($rootPage['uid']);

        $tmpl = GeneralUtility::makeInstance(ExtendedTemplateService::class);
        $tmpl->tt_track = false; // Do not log time-performance information
        $tmpl->init();
        $tmpl->runThroughTemplates($rootLine); // This generates the constants/config + hierarchy info for the template.

        // fake micro TSFE to get correct condition parsing
        $GLOBALS['TSFE'] = new \stdClass();
        $GLOBALS['TSFE']->tmpl = new \stdClass();
        $GLOBALS['TSFE']->cObjectDepthCounter = 50;
        $GLOBALS['TSFE']->tmpl->rootLine = $rootLine;
        $GLOBALS['TSFE']->sys_page = $pageSelect;
        $GLOBALS['TSFE']->id = $rootPage['uid'];
        $GLOBALS['TSFE']->page = $rootPage;

        $tmpl->generateConfig();
        $GLOBALS['TSFE']->tmpl->setup = $tmpl->setup;

        $configuration = Util::getSolrConfigurationFromPageId($rootPage['uid'], false, $languageId);

        $solrIsEnabledAndConfigured = $configuration->getEnabled() && $configuration->getSolrHasConnectionConfiguration();
        if (!$solrIsEnabledAndConfigured) {
            return $connection;
        }

        $connection = [
            'connectionKey' => $connectionKey,
            'rootPageTitle' => $rootPage['title'],
            'rootPageUid' => $rootPage['uid'],
            'read' => [
                'scheme' => $configuration->getSolrScheme(),
                'host' => $configuration->getSolrHost(),
                'port' => $configuration->getSolrPort(),
                'path' => $configuration->getSolrPath(),
                'username' => $configuration->getSolrUsername(),
                'password' => $configuration->getSolrPassword(),
                'timeout' => $configuration->getSolrTimeout()
            ],
            'write' => [
                'scheme' => $configuration->getSolrScheme('http', 'write'),
                'host' => $configuration->getSolrHost('localhost', 'write'),
                'port' => $configuration->getSolrPort(8983, 'write'),
                'path' => $configuration->getSolrPath('/solr/core_en/', 'write'),
                'username' => $configuration->getSolrUsername('', 'write'),
                'password' => $configuration->getSolrPassword('', 'write'),
                'timeout' => $configuration->getSolrTimeout(0, 'write')
            ],

            'language' => $languageId
        ];

        $connection['label'] = $this->buildConnectionLabel($connection);
        return $connection;
    }
protected function getConfiguredSolrConnectionByRootPage(array $rootPage, $languageId)
    {
        $connection = [];

        $languageId = (int)$languageId;
        GeneralUtility::_GETset($languageId, 'L');
        $connectionKey = $rootPage['uid'] . '|' . $languageId;

        $pageSelect = GeneralUtility::makeInstance(PageRepository::class);
        $rootLine = $pageSelect->getRootLine($rootPage['uid']);

        $tmpl = GeneralUtility::makeInstance(ExtendedTemplateService::class);
        $tmpl->tt_track = false; // Do not log time-performance information
        $tmpl->init();
        $tmpl->runThroughTemplates($rootLine); // This generates the constants/config + hierarchy info for the template.

        // fake micro TSFE to get correct condition parsing
        $GLOBALS['TSFE'] = new \stdClass();
        $GLOBALS['TSFE']->tmpl = new \stdClass();
        $GLOBALS['TSFE']->cObjectDepthCounter = 50;
        $GLOBALS['TSFE']->tmpl->rootLine = $rootLine;
        $GLOBALS['TSFE']->sys_page = $pageSelect;
        $GLOBALS['TSFE']->id = $rootPage['uid'];
        $GLOBALS['TSFE']->page = $rootPage;

        $tmpl->generateConfig();
        $GLOBALS['TSFE']->tmpl->setup = $tmpl->setup;

        $configuration = Util::getSolrConfigurationFromPageId($rootPage['uid'], false, $languageId);

        $solrIsEnabledAndConfigured = $configuration->getEnabled() && $configuration->getSolrHasConnectionConfiguration();
        if (!$solrIsEnabledAndConfigured) {
            return $connection;
        }

        $connection = [
            'connectionKey' => $connectionKey,
            'rootPageTitle' => $rootPage['title'],
            'rootPageUid' => $rootPage['uid'],
            'read' => [
                'scheme' => $configuration->getSolrScheme(),
                'host' => $configuration->getSolrHost(),
                'port' => $configuration->getSolrPort(),
                'path' => $configuration->getSolrPath(),
                'username' => $configuration->getSolrUsername(),
                'password' => $configuration->getSolrPassword(),
                'timeout' => $configuration->getSolrTimeout()
            ],
            'write' => [
                'scheme' => $configuration->getSolrScheme('http', 'write'),
                'host' => $configuration->getSolrHost('localhost', 'write'),
                'port' => $configuration->getSolrPort(8983, 'write'),
                'path' => $configuration->getSolrPath('/solr/core_en/', 'write'),
                'username' => $configuration->getSolrUsername('', 'write'),
                'password' => $configuration->getSolrPassword('', 'write'),
                'timeout' => $configuration->getSolrTimeout(0, 'write')
            ],

            'language' => $languageId
        ];

        $connection['label'] = $this->buildConnectionLabel($connection);
        return $connection;
    }
protected function getConfiguredSolrConnectionByRootPage ( array $ rootPage , $ languageId ) { $ connection = [ ] ; $ languageId = ( int ) $ languageId ; GeneralUtility :: _GETset ( $ languageId , 'L' ) ; $ connectionKey = $ rootPage [ 'uid' ] . '|' . $ languageId ; $ pageSelect = GeneralUtility :: makeInstance ( PageRepository :: class ) ; $ rootLine = $ pageSelect -> getRootLine ( $ rootPage [ 'uid' ] ) ; $ tmpl = GeneralUtility :: makeInstance ( ExtendedTemplateService :: class ) ; $ tmpl -> tt_track = false ; // Do not log time-performance information $ tmpl -> init ( ) ; $ tmpl -> runThroughTemplates ( $ rootLine ) ; // This generates the constants/config + hierarchy info for the template. // fake micro TSFE to get correct condition parsing $ GLOBALS [ 'TSFE' ] = new \ stdClass ( ) ; $ GLOBALS [ 'TSFE' ] -> tmpl = new \ stdClass ( ) ; $ GLOBALS [ 'TSFE' ] -> cObjectDepthCounter = 50 ; $ GLOBALS [ 'TSFE' ] -> tmpl -> rootLine = $ rootLine ; $ GLOBALS [ 'TSFE' ] -> sys_page = $ pageSelect ; $ GLOBALS [ 'TSFE' ] -> id = $ rootPage [ 'uid' ] ; $ GLOBALS [ 'TSFE' ] -> page = $ rootPage ; $ tmpl -> generateConfig ( ) ; $ GLOBALS [ 'TSFE' ] -> tmpl -> setup = $ tmpl -> setup ; $ configuration = Util :: getSolrConfigurationFromPageId ( $ rootPage [ 'uid' ] , false , $ languageId ) ; $ solrIsEnabledAndConfigured = $ configuration -> getEnabled ( ) && $ configuration -> getSolrHasConnectionConfiguration ( ) ; if ( ! $ solrIsEnabledAndConfigured ) { return $ connection ; } $ connection = [ 'connectionKey' => $ connectionKey , 'rootPageTitle' => $ rootPage [ 'title' ] , 'rootPageUid' => $ rootPage [ 'uid' ] , 'read' => [ 'scheme' => $ configuration -> getSolrScheme ( ) , 'host' => $ configuration -> getSolrHost ( ) , 'port' => $ configuration -> getSolrPort ( ) , 'path' => $ configuration -> getSolrPath ( ) , 'username' => $ configuration -> getSolrUsername ( ) , 'password' => $ configuration -> getSolrPassword ( ) , 'timeout' => $ configuration -> getSolrTimeout ( ) ] , 'write' => [ 'scheme' => $ configuration -> getSolrScheme ( 'http' , 'write' ) , 'host' => $ configuration -> getSolrHost ( 'localhost' , 'write' ) , 'port' => $ configuration -> getSolrPort ( 8983 , 'write' ) , 'path' => $ configuration -> getSolrPath ( '/solr/core_en/' , 'write' ) , 'username' => $ configuration -> getSolrUsername ( '' , 'write' ) , 'password' => $ configuration -> getSolrPassword ( '' , 'write' ) , 'timeout' => $ configuration -> getSolrTimeout ( 0 , 'write' ) ] , 'language' => $ languageId ] ; $ connection [ 'label' ] = $ this -> buildConnectionLabel ( $ connection ) ; return $ connection ; }
Gets the configured Solr connection for a specific root page and language ID.

@param array $rootPage A root page record with at least title and uid
@param int $languageId ID of a system language
@return array A solr connection configuration.
Gets the configured Solr connection for a specific root page and language ID .