Passed
Push — master ( 9fb38e...3b1a8c )
by Timo
04:38
created

SiteRepository::getDefaultLanguage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 13
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
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\System\Cache\TwoLevelCache;
30
use ApacheSolrForTypo3\Solr\System\Configuration\ExtensionConfiguration;
31
use ApacheSolrForTypo3\Solr\System\Records\Pages\PagesRepository;
32
use ApacheSolrForTypo3\Solr\System\Records\SystemLanguage\SystemLanguageRepository;
33
use ApacheSolrForTypo3\Solr\System\Service\SiteService;
34
use ApacheSolrForTypo3\Solr\System\Util\SiteUtility;
35
use ApacheSolrForTypo3\Solr\Util;
36
use TYPO3\CMS\Backend\Utility\BackendUtility;
37
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
38
use TYPO3\CMS\Core\Registry;
39
use TYPO3\CMS\Core\Site\SiteFinder;
40
use TYPO3\CMS\Core\Utility\GeneralUtility;
41
use TYPO3\CMS\Core\Utility\RootlineUtility;
42
use TYPO3\CMS\Frontend\Compatibility\LegacyDomainResolver;
43
44
/**
45
 * SiteRepository
46
 *
47
 * Responsible to retrieve instances of Site objects
48
 *
49
 * @author Thomas Hohn <[email protected]>
50
 */
51
class SiteRepository
52
{
53
    /**
54
     * Rootpage resolver
55
     *
56
     * @var RootPageResolver
57
     */
58
    protected $rootPageResolver;
59
60
    /**
61
     * @var TwoLevelCache
62
     */
63
    protected $runtimeCache;
64
65
    /**
66
     * @var Registry
67
     */
68
    protected $registry;
69
70
    /**
71
     * @var SiteFinder
72
     */
73
    protected $siteFinder;
74
75
    /**
76
     * @var ExtensionConfiguration
77
     */
78
    protected $extensionConfiguration;
79
80
    /**
81
     * SiteRepository constructor.
82
     *
83
     * @param RootPageResolver|null $rootPageResolver
84
     * @param TwoLevelCache|null $twoLevelCache
85
     * @param Registry|null $registry
86
     * @param SiteFinder|null $siteFinder
87
     * @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...
88 187
     */
89
    public function __construct(RootPageResolver $rootPageResolver = null, TwoLevelCache $twoLevelCache = null, Registry $registry = null, SiteFinder $siteFinder = null, ExtensionConfiguration $extensionConfiguration = null)
90 187
    {
91 187
        $this->rootPageResolver = $rootPageResolver ?? GeneralUtility::makeInstance(RootPageResolver::class);
92 187
        $this->runtimeCache = $twoLevelCache ?? GeneralUtility::makeInstance(TwoLevelCache::class, /** @scrutinizer ignore-type */'cache_runtime');
93 187
        $this->registry = $registry ?? GeneralUtility::makeInstance(Registry::class);
94 187
        $this->siteFinder = $siteFinder ?? GeneralUtility::makeInstance(SiteFinder::class);
95 187
        $this->extensionConfiguration = $extensionConfiguration ?? GeneralUtility::makeInstance(ExtensionConfiguration::class);
96
    }
97
98
    /**
99
     * Gets the Site for a specific page Id.
100
     *
101
     * @param int $pageId The page Id to get a Site object for.
102
     * @param string $mountPointIdentifier
103
     * @return SiteInterface Site for the given page Id.
104 111
     */
105
    public function getSiteByPageId($pageId, $mountPointIdentifier = '')
106 111
    {
107 111
        $rootPageId = $this->rootPageResolver->getRootPageId($pageId, false, $mountPointIdentifier);
108
        return $this->getSiteByRootPageId($rootPageId);
109
    }
110
111
    /**
112
     * Gets the Site for a specific root page Id.
113
     *
114
     * @param int $rootPageId Root page Id to get a Site object for.
115
     * @return SiteInterface Site for the given page Id.
116 128
     */
117
    public function getSiteByRootPageId($rootPageId)
118 128
    {
119
        $cacheId = 'SiteRepository' . '_' . 'getSiteByPageId' . '_' . $rootPageId;
120 128
121 128
        $methodResult = $this->runtimeCache->get($cacheId);
122 96
        if (!empty($methodResult)) {
123
            return $methodResult;
124
        }
125 128
126 121
        $methodResult = $this->buildSite($rootPageId);
127
        $this->runtimeCache->set($cacheId, $methodResult);
128 121
129
        return $methodResult;
130
    }
131
132
    /**
133
     * Returns the first available Site.
134
     *
135
     * @param bool $stopOnInvalidSite
136
     * @throws \Exception
137
     * @return Site
138 19
     */
139
    public function getFirstAvailableSite($stopOnInvalidSite = false)
140 19
    {
141 19
        $sites = $this->getAvailableSites($stopOnInvalidSite);
142
        return array_shift($sites);
143
    }
144
145
    /**
146
     * Gets all available TYPO3 sites with Solr configured.
147
     *
148
     * @param bool $stopOnInvalidSite
149
     * @throws \Exception
150
     * @return Site[] An array of availablesites
151 73
     */
152
    public function getAvailableSites($stopOnInvalidSite = false)
153 73
    {
154
        $cacheId = 'SiteRepository' . '_' . 'getAvailableSites';
155 73
156 73
        $sites = $this->runtimeCache->get($cacheId);
157 13
        if (!empty($sites)) {
158
            return $sites;
159
        }
160 73
161
        if ($this->extensionConfiguration->getIsAllowLegacySiteModeEnabled()) {
162
            $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

162
            $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...
163 73
        } else {
164
            $sites = $this->getAvailableTYPO3ManagedSites($stopOnInvalidSite);
165
        }
166 73
167
        $this->runtimeCache->set($cacheId, $sites);
168 73
169
        return $sites;
170
    }
171
172
    /**
173
     * @deprecated deprecated since EXT:solr 10 will be removed with EXT:solr 11 please use the site handling now
174
     * @param bool $stopOnInvalidSite
175
     * @return array
176
     */
177
    protected function getAvailableLegacySites(bool $stopOnInvalidSite): array
178
    {
179
        $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

179
        $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...
180
        if(empty($serversFromRegistry)) {
181
            return [];
182
        }
183
184
        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);
185
        $legacySites = [];
186
        foreach ($serversFromRegistry as $server) {
187
            if (isset($legacySites[$server['rootPageUid']])) {
188
                //get each site only once
189
                continue;
190
            }
191
192
            try {
193
                $legacySites[$server['rootPageUid']] = $this->buildSite($server['rootPageUid']);
194
            } catch (\InvalidArgumentException $e) {
195
                if ($stopOnInvalidSite) {
196
                    throw $e;
197
                }
198
            }
199
        }
200
        return $legacySites;
201
    }
202
203
204
    /**
205
     * @param bool $stopOnInvalidSite
206
     * @return array
207
     * @throws \Exception
208 73
     */
209
    protected function getAvailableTYPO3ManagedSites(bool $stopOnInvalidSite): array
210 73
    {
211 73
        $typo3ManagedSolrSites = [];
212 73
        $typo3Sites = $this->siteFinder->getAllSites();
213
        foreach ($typo3Sites as $typo3Site) {
214 73
            try {
215 73
                $rootPageId = $typo3Site->getRootPageId();
216
                if (isset($typo3ManagedSolrSites[$rootPageId])) {
217
                    //get each site only once
218
                    continue;
219
                }
220 73
221
                $typo3ManagedSolrSites[$rootPageId] = $this->buildSite($rootPageId);
222 62
223 62
            } catch (\Exception $e) {
224
                if ($stopOnInvalidSite) {
225
                    throw $e;
226
                }
227
            }
228 73
        }
229
        return $typo3ManagedSolrSites;
230
    }
231
232
    /**
233
     * Gets the system languages (IDs) for which Solr connections have been
234
     * configured.
235
     *
236
     * @param Site $site
237
     * @return array
238
     * @throws \ApacheSolrForTypo3\Solr\NoSolrConnectionFoundException
239
     * @deprecated use $site->getConnectionConfig
240
     */
241
    public function getAllLanguages(Site $site)
242
    {
243
        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);
244
245
        $siteLanguages = [];
246
        foreach ($site->getAllSolrConnectionConfigurations() as $solrConnectionConfiguration) {
247
            $siteLanguages[] = $solrConnectionConfiguration['language'];
248
        }
249
250
        return $siteLanguages;
251
    }
252
253
    /**
254
     * Creates an instance of the Site object.
255
     *
256
     * @param integer $rootPageId
257
     * @throws \InvalidArgumentException
258
     * @return SiteInterface
259 162
     */
260
    protected function buildSite($rootPageId)
261 162
    {
262
        if (empty($rootPageId)) {
263
            throw new \InvalidArgumentException('Root page id can not be empty');
264 162
        }
265
        $rootPageRecord = (array)BackendUtility::getRecord('pages', $rootPageId);
266 162
267
        $this->validateRootPageRecord($rootPageId, $rootPageRecord);
268
269 151
        //@todo The handling of the legacy site can be removed in EXT:solr 11
270
        if (!SiteUtility::getIsSiteManagedSite($rootPageId) && $this->extensionConfiguration->getIsAllowLegacySiteModeEnabled()) {
271
            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

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

407
        $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...
408
        $siteHash = $this->getSiteHashForDomain($domain);
409
        $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

409
        $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...
410
        $pageRepository = GeneralUtility::makeInstance(PagesRepository::class);
411
        $availableLanguageIds = GeneralUtility::makeInstance(SystemLanguageRepository::class)->findSystemLanguages();
412
413
        return GeneralUtility::makeInstance(
414
            LegacySite::class,
415
            /** @scrutinizer ignore-type */
416
            $solrConfiguration,
417
            /** @scrutinizer ignore-type */
418
            $rootPageRecord,
419
            /** @scrutinizer ignore-type */
420
            $domain,
421
            /** @scrutinizer ignore-type */
422
            $siteHash,
423
            /** @scrutinizer ignore-type */
424
            $pageRepository,
425
            /** @scrutinizer ignore-type */
426
            $defaultLanguage,
427
            /** @scrutinizer ignore-type */
428
            $availableLanguageIds
429
        );
430
    }
431
432
    /**
433
     * @param array $rootPageRecord
434
     * @return Typo3ManagedSite
435 151
     */
436
    protected function buildTypo3ManagedSite(array $rootPageRecord): Typo3ManagedSite
437 151
    {
438
        $solrConfiguration = Util::getSolrConfigurationFromPageId($rootPageRecord['uid']);
439 151
        /** @var \TYPO3\CMS\Core\Site\Entity\Site $typo3Site */
440 151
        try {
441
            $typo3Site = $this->siteFinder->getSiteByPageId($rootPageRecord['uid']);
442 151
        } catch (SiteNotFoundException $e) {
443 151
            throw new \InvalidArgumentException("No site found with uid ". intval($rootPageRecord['uid']));
444 151
        }
445 151
        $domain = $typo3Site->getBase()->getHost();
446 151
447 151
        $siteHash = $this->getSiteHashForDomain($domain);
448
        $defaultLanguage = $typo3Site->getDefaultLanguage()->getLanguageId();
449 151
        $pageRepository = GeneralUtility::makeInstance(PagesRepository::class);
450
        $availableLanguageIds = array_map(function($language) {
451 151
            return $language->getLanguageId();
452 151
        }, $typo3Site->getLanguages());
453 151
454 151
        $solrConnectionConfigurations = [];
455 151
456 151
        foreach ($availableLanguageIds as $languageUid) {
457 151
            $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

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