SiteRepository::buildTypo3ManagedSite()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 77
Code Lines 52

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
eloc 52
dl 0
loc 77
ccs 0
cts 0
cp 0
rs 9.0472
c 0
b 0
f 0
cc 4
nc 4
nop 1
crap 20

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace ApacheSolrForTypo3\Solr\Domain\Site;
4
5
/***************************************************************
6
 *  Copyright notice
7
 *
8
 *  (c) 2017 - Thomas Hohn <[email protected]>
9
 *  All rights reserved
10
 *
11
 *  This script is part of the TYPO3 project. The TYPO3 project is
12
 *  free software; you can redistribute it and/or modify
13
 *  it under the terms of the GNU General Public License as published by
14
 *  the Free Software Foundation; either version 3 of the License, or
15
 *  (at your option) any later version.
16
 *
17
 *  The GNU General Public License can be found at
18
 *  http://www.gnu.org/copyleft/gpl.html.
19
 *
20
 *  This script is distributed in the hope that it will be useful,
21
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 *  GNU General Public License for more details.
24
 *
25
 *  This copyright notice MUST APPEAR in all copies of the script!
26
 ***************************************************************/
27
28
use ApacheSolrForTypo3\Solr\Domain\Index\Queue\RecordMonitor\Helper\RootPageResolver;
29
use ApacheSolrForTypo3\Solr\FrontendEnvironment;
30
use ApacheSolrForTypo3\Solr\System\Cache\TwoLevelCache;
31
use ApacheSolrForTypo3\Solr\System\Configuration\ExtensionConfiguration;
32
use ApacheSolrForTypo3\Solr\System\Records\Pages\PagesRepository;
33
use ApacheSolrForTypo3\Solr\System\Records\SystemLanguage\SystemLanguageRepository;
34
use ApacheSolrForTypo3\Solr\System\Service\SiteService;
35
use ApacheSolrForTypo3\Solr\System\Util\SiteUtility;
36
use ApacheSolrForTypo3\Solr\Util;
37
use TYPO3\CMS\Backend\Utility\BackendUtility;
38
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
39
use TYPO3\CMS\Core\Registry;
40
use TYPO3\CMS\Core\Site\SiteFinder;
41
use TYPO3\CMS\Core\Utility\GeneralUtility;
42
use TYPO3\CMS\Core\Utility\RootlineUtility;
43
use TYPO3\CMS\Frontend\Compatibility\LegacyDomainResolver;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Frontend\Compa...ty\LegacyDomainResolver was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
44
45
/**
46
 * SiteRepository
47
 *
48
 * Responsible to retrieve instances of Site objects
49
 *
50
 * @author Thomas Hohn <[email protected]>
51
 */
52
class SiteRepository
53
{
54
    /**
55
     * Rootpage resolver
56
     *
57
     * @var RootPageResolver
58
     */
59
    protected $rootPageResolver;
60
61
    /**
62
     * @var TwoLevelCache
63
     */
64
    protected $runtimeCache;
65
66
    /**
67
     * @var Registry
68
     */
69
    protected $registry;
70
71
    /**
72 169
     * @var SiteFinder
73
     */
74 169
    protected $siteFinder;
75 169
76 169
    /**
77 169
     * @var ExtensionConfiguration
78
     */
79
    protected $extensionConfiguration;
80
81
    /**
82
     * @var FrontendEnvironment
83
     */
84
    protected $frontendEnvironment = null;
85
86 107
    /**
87
     * SiteRepository constructor.
88 107
     *
89 107
     * @param RootPageResolver|null $rootPageResolver
90
     * @param TwoLevelCache|null $twoLevelCache
91
     * @param Registry|null $registry
92
     * @param SiteFinder|null $siteFinder
93
     * @param ExtensionConfiguration| null
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $ExtensionConfiguration| is correct as it would always require null to be passed?
Loading history...
94
     */
95
    public function __construct(
96
        RootPageResolver $rootPageResolver = null,
97
        TwoLevelCache $twoLevelCache = null,
98 123
        Registry $registry = null,
99
        SiteFinder $siteFinder = null,
100 123
        ExtensionConfiguration $extensionConfiguration = null,
101
        FrontendEnvironment $frontendEnvironment = null
102 123
    )
103 123
    {
104 92
        $this->rootPageResolver = $rootPageResolver ?? GeneralUtility::makeInstance(RootPageResolver::class);
105
        $this->runtimeCache = $twoLevelCache ?? GeneralUtility::makeInstance(TwoLevelCache::class, /** @scrutinizer ignore-type */'cache_runtime');
106
        $this->registry = $registry ?? GeneralUtility::makeInstance(Registry::class);
107 123
        $this->siteFinder = $siteFinder ?? GeneralUtility::makeInstance(SiteFinder::class);
108 118
        $this->extensionConfiguration = $extensionConfiguration ?? GeneralUtility::makeInstance(ExtensionConfiguration::class);
109
        $this->frontendEnvironment = $frontendEnvironment ?? GeneralUtility::makeInstance(FrontendEnvironment::class);
110 118
    }
111
112
    /**
113
     * Gets the Site for a specific page Id.
114
     *
115
     * @param int $pageId The page Id to get a Site object for.
116
     * @param string $mountPointIdentifier
117
     * @return SiteInterface Site for the given page Id.
118
     */
119 22
    public function getSiteByPageId($pageId, $mountPointIdentifier = '')
120
    {
121 22
        $rootPageId = $this->rootPageResolver->getRootPageId($pageId, false, $mountPointIdentifier);
122 22
        return $this->getSiteByRootPageId($rootPageId);
123
    }
124
125
    /**
126
     * Gets the Site for a specific root page Id.
127
     *
128
     * @param int $rootPageId Root page Id to get a Site object for.
129
     * @return SiteInterface Site for the given page Id.
130
     */
131 67
    public function getSiteByRootPageId($rootPageId)
132
    {
133 67
        $cacheId = 'SiteRepository' . '_' . 'getSiteByPageId' . '_' . $rootPageId;
134 67
135
        $methodResult = $this->runtimeCache->get($cacheId);
136 67
        if (!empty($methodResult)) {
137 67
            return $methodResult;
138 16
        }
139
140
        $methodResult = $this->buildSite($rootPageId);
141 67
        $this->runtimeCache->set($cacheId, $methodResult);
142 67
143 67
        return $methodResult;
144
    }
145 9
146
    /**
147
     * Returns the first available Site.
148
     *
149 67
     * @param bool $stopOnInvalidSite
150
     * @throws \Exception
151
     * @return Site
152 67
     */
153
    public function getFirstAvailableSite($stopOnInvalidSite = false)
154
    {
155
        $sites = $this->getAvailableSites($stopOnInvalidSite);
156
        return array_shift($sites);
157 67
    }
158 67
159
    /**
160 67
     * Gets all available TYPO3 sites with Solr configured.
161
     *
162
     * @param bool $stopOnInvalidSite
163
     * @throws \Exception
164
     * @return Site[] An array of availablesites
165
     */
166
    public function getAvailableSites($stopOnInvalidSite = false)
167
    {
168
        $cacheId = 'SiteRepository' . '_' . 'getAvailableSites';
169 1
170
        $sites = $this->runtimeCache->get($cacheId);
171 1
        if (!empty($sites)) {
172 1
            return $sites;
173
        }
174 1
175 1
        if ($this->extensionConfiguration->getIsAllowLegacySiteModeEnabled()) {
176
            $sites = $this->getAvailableLegacySites($stopOnInvalidSite);
0 ignored issues
show
Deprecated Code introduced by
The function ApacheSolrForTypo3\Solr\...tAvailableLegacySites() has been deprecated: deprecated since EXT:solr 10 will be removed with EXT:solr 11 please use the site handling now ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

176
            $sites = /** @scrutinizer ignore-deprecated */ $this->getAvailableLegacySites($stopOnInvalidSite);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
177 1
        } else {
178 1
            $sites = $this->getAvailableTYPO3ManagedSites($stopOnInvalidSite);
179
        }
180
181
        $this->runtimeCache->set($cacheId, $sites);
182 1
183
        return $sites;
184
    }
185
186
    /**
187
     * @deprecated deprecated since EXT:solr 10 will be removed with EXT:solr 11 please use the site handling now
188
     * @param bool $stopOnInvalidSite
189
     * @return array
190
     */
191
    protected function getAvailableLegacySites(bool $stopOnInvalidSite): array
192 149
    {
193
        $serversFromRegistry = $this->getSolrServersFromRegistry();
0 ignored issues
show
Deprecated Code introduced by
The function ApacheSolrForTypo3\Solr\...lrServersFromRegistry() has been deprecated: This method is only required for old solr based sites. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

193
        $serversFromRegistry = /** @scrutinizer ignore-deprecated */ $this->getSolrServersFromRegistry();

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
194 149
        if(empty($serversFromRegistry)) {
195
            return [];
196 149
        }
197 144
198 144
        trigger_error('solr:deprecation: Method getAvailableLegacySites is deprecated since EXT:solr 10 and will be removed in v11, please use the site handling to configure EXT:solr', E_USER_DEPRECATED);
199 144
        $legacySites = [];
200
        foreach ($serversFromRegistry as $server) {
201 144
            if (isset($legacySites[$server['rootPageUid']])) {
202 144
                //get each site only once
203 144
                continue;
204 144
            }
205 144
206 144
            try {
207
                $legacySites[$server['rootPageUid']] = $this->buildSite($server['rootPageUid']);
208
            } catch (\InvalidArgumentException $e) {
209
                if ($stopOnInvalidSite) {
210
                    throw $e;
211
                }
212
            }
213
        }
214
        return $legacySites;
215 67
    }
216
217 67
218 67
    /**
219
     * @param bool $stopOnInvalidSite
220
     * @return array
221
     * @throws \Exception
222
     */
223
    protected function getAvailableTYPO3ManagedSites(bool $stopOnInvalidSite): array
224
    {
225 144
        $typo3ManagedSolrSites = [];
226
        $typo3Sites = $this->siteFinder->getAllSites();
227
        foreach ($typo3Sites as $typo3Site) {
228 144
            try {
229 144
                $rootPageId = $typo3Site->getRootPageId();
230 144
                if (isset($typo3ManagedSolrSites[$rootPageId])) {
231 143
                    //get each site only once
232 143
                    continue;
233 143
                }
234 143
235
                $typo3ManagedSolrSites[$rootPageId] = $this->buildSite($rootPageId);
236
237 1
            } catch (\Exception $e) {
238
                if ($stopOnInvalidSite) {
239
                    throw $e;
240
                }
241
            }
242
        }
243
        return $typo3ManagedSolrSites;
244 144
    }
245
246
    /**
247 144
     * Gets the system languages (IDs) for which Solr connections have been
248 144
     * configured.
249 144
     *
250
     * @param Site $site
251
     * @return array
252
     * @throws \ApacheSolrForTypo3\Solr\NoSolrConnectionFoundException
253
     * @deprecated use $site->getConnectionConfig
254
     */
255
    public function getAllLanguages(Site $site)
256
    {
257 149
        trigger_error('solr:deprecation: Method getAllLanguages is deprecated since EXT:solr 10 and will be removed in v11, use  $site->getConnectionConfig instead', E_USER_DEPRECATED);
258
259 149
        $siteLanguages = [];
260 4
        foreach ($site->getAllSolrConnectionConfigurations() as $solrConnectionConfiguration) {
261 4
            $siteLanguages[] = $solrConnectionConfiguration['language'];
262 4
        }
263
264
        return $siteLanguages;
265
    }
266 145
267 1
    /**
268 1
     * Creates an instance of the Site object.
269 1
     *
270
     * @param integer $rootPageId
271
     * @throws \InvalidArgumentException
272 144
     * @return SiteInterface
273
     */
274
    protected function buildSite($rootPageId)
275
    {
276
        if (empty($rootPageId)) {
277
            throw new \InvalidArgumentException('Root page id can not be empty');
278
        }
279
        $rootPageRecord = (array)BackendUtility::getRecord('pages', $rootPageId);
280
281
        $this->validateRootPageRecord($rootPageId, $rootPageRecord);
282
283
        //@todo The handling of the legacy site can be removed in EXT:solr 11
284
        if (!SiteUtility::getIsSiteManagedSite($rootPageId) && $this->extensionConfiguration->getIsAllowLegacySiteModeEnabled()) {
285
            return $this->buildLegacySite($rootPageRecord);
0 ignored issues
show
Deprecated Code introduced by
The function ApacheSolrForTypo3\Solr\...tory::buildLegacySite() has been deprecated: buildLegacySite is deprecated and will be removed in EXT:solr 11. Please configure your system with the TYPO3 sitehandling ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

285
            return /** @scrutinizer ignore-deprecated */ $this->buildLegacySite($rootPageRecord);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
286
        }
287
288
        return $this->buildTypo3ManagedSite($rootPageRecord);
289
    }
290
291
    /**
292
     * Retrieves the default language by the rootPageId of a site.
293
     *
294
     * @param int $rootPageId
295
     * @return int|mixed
296
     * @deprecated Use Site directly
297
     */
298
    protected function getDefaultLanguage($rootPageId)
299
    {
300
        trigger_error('solr:deprecation: Method getDefaultLanguage is deprecated since EXT:solr 10 and will be removed in v11, use  the site directly instead', E_USER_DEPRECATED);
301
302
        $siteDefaultLanguage = 0;
303
304
        $configuration = $this->frontendEnvironment->getConfigurationFromPageId($rootPageId, 'config');
305
306
        $siteDefaultLanguage = $configuration->getValueByPathOrDefaultValue('sys_language_uid', $siteDefaultLanguage);
307
        // default language is set through default L GET parameter -> overruling config.sys_language_uid
308
        $siteDefaultLanguage = $configuration->getValueByPathOrDefaultValue('defaultGetVars.L', $siteDefaultLanguage);
309
310
        return $siteDefaultLanguage;
311
    }
312
313
    /**
314
     * Retrieves the configured solr servers from the registry.
315
     *
316
     * @deprecated This method is only required for old solr based sites.
317
     * @return array
318
     */
319
    protected function getSolrServersFromRegistry()
320
    {
321
        trigger_error('solr:deprecation: Method getSolrServersFromRegistry is deprecated since EXT:solr 10 and will be removed in v11, use sitehanlding instead', E_USER_DEPRECATED);
322
323
        $servers = (array)$this->registry->get('tx_solr', 'servers', []);
324
        return $servers;
325
    }
326
327
    /**
328
     * @param $rootPageId
329
     * @deprecated This method is only required for old solr based sites.
330
     * @return NULL|string
331
     */
332
    protected function getDomainFromConfigurationOrFallbackToDomainRecord($rootPageId)
333
    {
334
        trigger_error('solr:deprecation: Method getDomainFromConfigurationOrFallbackToDomainRecord is deprecated since EXT:solr 10 and will be removed in v11, use sitehanlding instead', E_USER_DEPRECATED);
335
336
        /** @var $siteService SiteService */
337
        $siteService = GeneralUtility::makeInstance(SiteService::class);
338
        $domain = $siteService->getFirstDomainForRootPage($rootPageId);
339
        if ($domain === '') {
340
            $rootlineUtility = GeneralUtility::makeInstance(RootlineUtility::class, $rootPageId);
341
            try {
342
                $rootLine = $rootlineUtility->get();
343
            } catch (\RuntimeException $e) {
344
                $rootLine = [];
345
            }
346
            $domain = $this->firstDomainRecordFromLegacyDomainResolver($rootLine);
347
            return (string)$domain;
348
        }
349
350
        return $domain;
351
    }
352
353
    /**
354
     * @param $rootLine
355
     * @return null|string
356
     */
357
    private function firstDomainRecordFromLegacyDomainResolver($rootLine)
358
    {
359
        trigger_error('Method firstDomainRecordFromLegacyDomainResolver is deprecated since EXT:solr 10 and will be removed in v11, use sitehandling instead.', E_USER_DEPRECATED);
360
        $domainResolver = GeneralUtility::makeInstance(LegacyDomainResolver::class);
361
        foreach ($rootLine as $row) {
362
            $domain = $domainResolver->matchRootPageId($row['uid']);
363
            if (is_array($domain)) {
364
                return rtrim($domain['domainName'], '/');
365
            }
366
        }
367
        return null;
368
    }
369
370
    /**
371
     * @param string $domain
372
     * @return string
373
     */
374
    protected function getSiteHashForDomain($domain)
375
    {
376
        /** @var $siteHashService SiteHashService */
377
        $siteHashService = GeneralUtility::makeInstance(SiteHashService::class);
378
        $siteHash = $siteHashService->getSiteHashForDomain($domain);
379
        return $siteHash;
380
    }
381
382
    /**
383
     * @param int $rootPageId
384
     * @param array $rootPageRecord
385
     * @throws \InvalidArgumentException
386
     */
387
    protected function validateRootPageRecord($rootPageId, $rootPageRecord)
388
    {
389
        if (empty($rootPageRecord)) {
390
            throw new \InvalidArgumentException(
391
                'The rootPageRecord for the given rootPageRecord ID \'' . $rootPageId . '\' could not be found in the database and can therefore not be used as site root rootPageRecord.',
392
                1487326416
393
            );
394
        }
395
396
        if (!Site::isRootPage($rootPageRecord)) {
397
            throw new \InvalidArgumentException(
398
                'The rootPageRecord for the given rootPageRecord ID \'' . $rootPageId . '\' is not marked as root rootPageRecord and can therefore not be used as site root rootPageRecord.',
399
                1309272922
400
            );
401
        }
402
    }
403
404
    /**
405
     *
406
     * @param array $rootPageRecord
407
     * @return LegacySite
408
     * @throws Exception\InvalidSiteConfigurationCombinationException
409
     * @deprecated buildLegacySite is deprecated and will be removed in EXT:solr 11. Please configure your system with the TYPO3 sitehandling
410
     */
411
    protected function buildLegacySite($rootPageRecord): LegacySite
412
    {
413
        trigger_error('solr:deprecation: You are using EXT:solr without sitehandling. This setup is deprecated and will be removed in EXT:solr 11', E_USER_DEPRECATED);
414
415
        if (!$this->extensionConfiguration->getIsAllowLegacySiteModeEnabled()) {
416
            throw new Exception\InvalidSiteConfigurationCombinationException('It was tried to boot legacy site configuration, but allowLegacySiteMode is not enabled. ' .
417
                'Please use site handling feature or enable legacy mode under "Settings":>"Extension Configuration":>"solr"', 1567770263);
418
        }
419
420
        $solrConfiguration = $this->frontendEnvironment->getSolrConfigurationFromPageId($rootPageRecord['uid']);
421
        $domain = $this->getDomainFromConfigurationOrFallbackToDomainRecord($rootPageRecord['uid']);
0 ignored issues
show
Deprecated Code introduced by
The function ApacheSolrForTypo3\Solr\...allbackToDomainRecord() has been deprecated: This method is only required for old solr based sites. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

421
        $domain = /** @scrutinizer ignore-deprecated */ $this->getDomainFromConfigurationOrFallbackToDomainRecord($rootPageRecord['uid']);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
422
        $siteHash = $this->getSiteHashForDomain($domain);
423
        $defaultLanguage = $this->getDefaultLanguage($rootPageRecord['uid']);
0 ignored issues
show
Deprecated Code introduced by
The function ApacheSolrForTypo3\Solr\...y::getDefaultLanguage() has been deprecated: Use Site directly ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

423
        $defaultLanguage = /** @scrutinizer ignore-deprecated */ $this->getDefaultLanguage($rootPageRecord['uid']);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
424
        $pageRepository = GeneralUtility::makeInstance(PagesRepository::class);
425
        $availableLanguageIds = GeneralUtility::makeInstance(SystemLanguageRepository::class)->findSystemLanguages();
426
427
        return GeneralUtility::makeInstance(
428
            LegacySite::class,
429
            /** @scrutinizer ignore-type */
430
            $solrConfiguration,
431
            /** @scrutinizer ignore-type */
432
            $rootPageRecord,
433
            /** @scrutinizer ignore-type */
434
            $domain,
435
            /** @scrutinizer ignore-type */
436
            $siteHash,
437
            /** @scrutinizer ignore-type */
438
            $pageRepository,
439
            /** @scrutinizer ignore-type */
440
            $defaultLanguage,
441
            /** @scrutinizer ignore-type */
442
            $availableLanguageIds
443
        );
444
    }
445
446
    /**
447
     * @param array $rootPageRecord
448
     * @return Typo3ManagedSite
449
     */
450
    protected function buildTypo3ManagedSite(array $rootPageRecord): ?Typo3ManagedSite
451
    {
452
        $solrConfiguration = $this->frontendEnvironment->getSolrConfigurationFromPageId($rootPageRecord['uid']);
453
        /** @var \TYPO3\CMS\Core\Site\Entity\Site $typo3Site */
454
        try {
455
            $typo3Site = $this->siteFinder->getSiteByPageId($rootPageRecord['uid']);
456
        } catch (SiteNotFoundException $e) {
457
            return null;
458
        }
459
        $domain = $typo3Site->getBase()->getHost();
460
461
        $siteHash = $this->getSiteHashForDomain($domain);
462
        $defaultLanguage = $typo3Site->getDefaultLanguage()->getLanguageId();
463
        $pageRepository = GeneralUtility::makeInstance(PagesRepository::class);
464
        $availableLanguageIds = array_map(function($language) {
465
            return $language->getLanguageId();
466
        }, $typo3Site->getLanguages());
467
468
        $solrConnectionConfigurations = [];
469
470
        foreach ($availableLanguageIds as $languageUid) {
471
            $solrEnabled = SiteUtility::getConnectionProperty($typo3Site, 'enabled', $languageUid, 'read', true);
0 ignored issues
show
Bug introduced by
true of type true is incompatible with the type null|string expected by parameter $defaultValue of ApacheSolrForTypo3\Solr\...getConnectionProperty(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

471
            $solrEnabled = SiteUtility::getConnectionProperty($typo3Site, 'enabled', $languageUid, 'read', /** @scrutinizer ignore-type */ true);
Loading history...
472
            if ($solrEnabled) {
473
                $solrConnectionConfigurations[$languageUid] = [
474
                    'connectionKey' =>  $rootPageRecord['uid'] . '|' . $languageUid,
475
                    'rootPageTitle' => $rootPageRecord['title'],
476
                    'rootPageUid' => $rootPageRecord['uid'],
477
                    'read' => [
478
                        'scheme' => SiteUtility::getConnectionProperty($typo3Site, 'scheme', $languageUid, 'read', 'http'),
479
                        'host' => SiteUtility::getConnectionProperty($typo3Site, 'host', $languageUid, 'read', 'localhost'),
480
                        'port' => (int)SiteUtility::getConnectionProperty($typo3Site, 'port', $languageUid, 'read', 8983),
481
                        // @todo: transform core to path
482
                        'path' =>
483
                            SiteUtility::getConnectionProperty($typo3Site, 'path', $languageUid, 'read', '/solr/') .
484
                            SiteUtility::getConnectionProperty($typo3Site, 'core', $languageUid, 'read', 'core_en') . '/' ,
485
                        'username' => SiteUtility::getConnectionProperty($typo3Site, 'username', $languageUid, 'read', ''),
486
                        'password' => SiteUtility::getConnectionProperty($typo3Site, 'password', $languageUid, 'read', ''),
487
                        'timeout' => SiteUtility::getConnectionProperty($typo3Site, 'timeout', $languageUid, 'read', 0)
488
                    ],
489
                    'write' => [
490
                        'scheme' => SiteUtility::getConnectionProperty($typo3Site, 'scheme', $languageUid, 'write', 'http'),
491
                        'host' => SiteUtility::getConnectionProperty($typo3Site, 'host', $languageUid, 'write', 'localhost'),
492
                        'port' => (int)SiteUtility::getConnectionProperty($typo3Site, 'port', $languageUid, 'write', 8983),
493
                        // @todo: transform core to path
494
                        'path' =>
495
                            SiteUtility::getConnectionProperty($typo3Site, 'path', $languageUid, 'read', '/solr/') .
496
                            SiteUtility::getConnectionProperty($typo3Site, 'core', $languageUid, 'read', 'core_en') . '/' ,
497
                        'username' => SiteUtility::getConnectionProperty($typo3Site, 'username', $languageUid, 'write', ''),
498
                        'password' => SiteUtility::getConnectionProperty($typo3Site, 'password', $languageUid, 'write', ''),
499
                        'timeout' => SiteUtility::getConnectionProperty($typo3Site, 'timeout', $languageUid, 'write', 0)
500
                    ],
501
502
                    'language' => $languageUid
503
                ];
504
            }
505
        }
506
507
        return GeneralUtility::makeInstance(
508
            Typo3ManagedSite::class,
509
            /** @scrutinizer ignore-type */
510
            $solrConfiguration,
511
            /** @scrutinizer ignore-type */
512
            $rootPageRecord,
513
            /** @scrutinizer ignore-type */
514
            $domain,
515
            /** @scrutinizer ignore-type */
516
            $siteHash,
517
            /** @scrutinizer ignore-type */
518
            $pageRepository,
519
            /** @scrutinizer ignore-type */
520
            $defaultLanguage,
521
            /** @scrutinizer ignore-type */
522
            $availableLanguageIds,
523
            /** @scrutinizer ignore-type */
524
            $solrConnectionConfigurations,
525
            /** @scrutinizer ignore-type */
526
            $typo3Site
527
        );
528
    }
529
530
}
531