Completed
Push — master ( 7da5f6...0e708e )
by Timo
44:47 queued 41:16
created

SiteRepository::getSiteHashForDomain()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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
     */
89 192
    public function __construct(RootPageResolver $rootPageResolver = null, TwoLevelCache $twoLevelCache = null, Registry $registry = null, SiteFinder $siteFinder = null, ExtensionConfiguration $extensionConfiguration = null)
90
    {
91 192
        $this->rootPageResolver = $rootPageResolver ?? GeneralUtility::makeInstance(RootPageResolver::class);
92 192
        $this->runtimeCache = $twoLevelCache ?? GeneralUtility::makeInstance(TwoLevelCache::class, /** @scrutinizer ignore-type */'cache_runtime');
93 192
        $this->registry = $registry ?? GeneralUtility::makeInstance(Registry::class);
94 192
        $this->siteFinder = $siteFinder ?? GeneralUtility::makeInstance(SiteFinder::class);
95 192
        $this->extensionConfiguration = $extensionConfiguration ?? GeneralUtility::makeInstance(ExtensionConfiguration::class);
96 192
    }
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
     */
105 114
    public function getSiteByPageId($pageId, $mountPointIdentifier = '')
106
    {
107 114
        $rootPageId = $this->rootPageResolver->getRootPageId($pageId, false, $mountPointIdentifier);
108 114
        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
     */
117 131
    public function getSiteByRootPageId($rootPageId)
118
    {
119 131
        $cacheId = 'SiteRepository' . '_' . 'getSiteByPageId' . '_' . $rootPageId;
120
121 131
        $methodResult = $this->runtimeCache->get($cacheId);
122 131
        if (!empty($methodResult)) {
123 98
            return $methodResult;
124
        }
125
126 131
        $methodResult = $this->buildSite($rootPageId);
127 124
        $this->runtimeCache->set($cacheId, $methodResult);
128
129 124
        return $methodResult;
130
    }
131
132
    /**
133
     * Returns the first available Site.
134
     *
135
     * @param bool $stopOnInvalidSite
136
     * @throws \Exception
137
     * @return Site
138
     */
139 21
    public function getFirstAvailableSite($stopOnInvalidSite = false)
140
    {
141 21
        $sites = $this->getAvailableSites($stopOnInvalidSite);
142 21
        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
     */
152 75
    public function getAvailableSites($stopOnInvalidSite = false)
153
    {
154 75
        $cacheId = 'SiteRepository' . '_' . 'getAvailableSites';
155
156 75
        $sites = $this->runtimeCache->get($cacheId);
157 75
        if (!empty($sites)) {
158 13
            return $sites;
159
        }
160
161 75
        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
        } else {
164 75
            $sites = $this->getAvailableTYPO3ManagedSites($stopOnInvalidSite);
165
        }
166
167 75
        $this->runtimeCache->set($cacheId, $sites);
168
169 75
        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
     */
209 75
    protected function getAvailableTYPO3ManagedSites(bool $stopOnInvalidSite): array
210
    {
211 75
        $typo3ManagedSolrSites = [];
212 75
        $typo3Sites = $this->siteFinder->getAllSites();
213 75
        foreach ($typo3Sites as $typo3Site) {
214
            try {
215 75
                $rootPageId = $typo3Site->getRootPageId();
216 75
                if (isset($typo3ManagedSolrSites[$rootPageId])) {
217
                    //get each site only once
218
                    continue;
219
                }
220
221 75
                $typo3ManagedSolrSites[$rootPageId] = $this->buildSite($rootPageId);
222
223 64
            } catch (\Exception $e) {
224 64
                if ($stopOnInvalidSite) {
225
                    throw $e;
226
                }
227
            }
228
        }
229 75
        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
     */
260 167
    protected function buildSite($rootPageId)
261
    {
262 167
        if (empty($rootPageId)) {
263
            throw new \InvalidArgumentException('Root page id can not be empty');
264
        }
265 167
        $rootPageRecord = (array)BackendUtility::getRecord('pages', $rootPageId);
266
267 167
        $this->validateRootPageRecord($rootPageId, $rootPageRecord);
268
269
        //@todo The handling of the legacy site can be removed in EXT:solr 11
270 156
        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
274 156
        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
     */
360 156
    protected function getSiteHashForDomain($domain)
361
    {
362
        /** @var $siteHashService SiteHashService */
363 156
        $siteHashService = GeneralUtility::makeInstance(SiteHashService::class);
364 156
        $siteHash = $siteHashService->getSiteHashForDomain($domain);
365 156
        return $siteHash;
366
    }
367
368
    /**
369
     * @param int $rootPageId
370
     * @param array $rootPageRecord
371
     * @throws \InvalidArgumentException
372
     */
373 167
    protected function validateRootPageRecord($rootPageId, $rootPageRecord)
374
    {
375 167
        if (empty($rootPageRecord)) {
376 69
            throw new \InvalidArgumentException(
377 69
                '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 69
                1487326416
379
            );
380
        }
381
382 157
        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 3
                1309272922
386
            );
387
        }
388 156
    }
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
     */
436 156
    protected function buildTypo3ManagedSite(array $rootPageRecord): ?Typo3ManagedSite
437
    {
438 156
        $solrConfiguration = Util::getSolrConfigurationFromPageId($rootPageRecord['uid']);
439
        /** @var \TYPO3\CMS\Core\Site\Entity\Site $typo3Site */
440
        try {
441 156
            $typo3Site = $this->siteFinder->getSiteByPageId($rootPageRecord['uid']);
442
        } catch (SiteNotFoundException $e) {
443
            return null;
444
        }
445 156
        $domain = $typo3Site->getBase()->getHost();
446
447 156
        $siteHash = $this->getSiteHashForDomain($domain);
448 156
        $defaultLanguage = $typo3Site->getDefaultLanguage()->getLanguageId();
449 156
        $pageRepository = GeneralUtility::makeInstance(PagesRepository::class);
450 156
        $availableLanguageIds = array_map(function($language) {
451 156
            return $language->getLanguageId();
452 156
        }, $typo3Site->getLanguages());
453
454 156
        $solrConnectionConfigurations = [];
455
456 156
        foreach ($availableLanguageIds as $languageUid) {
457 156
            $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 156
            if ($solrEnabled) {
459 156
                $solrConnectionConfigurations[$languageUid] = [
460 156
                    'connectionKey' =>  $rootPageRecord['uid'] . '|' . $languageUid,
461 156
                    'rootPageTitle' => $rootPageRecord['title'],
462 156
                    'rootPageUid' => $rootPageRecord['uid'],
463
                    'read' => [
464 156
                        'scheme' => SiteUtility::getConnectionProperty($typo3Site, 'scheme', $languageUid, 'read', 'http'),
465 156
                        'host' => SiteUtility::getConnectionProperty($typo3Site, 'host', $languageUid, 'read', 'localhost'),
466 156
                        'port' => (int)SiteUtility::getConnectionProperty($typo3Site, 'port', $languageUid, 'read', 8983),
467
                        // @todo: transform core to path
468
                        'path' =>
469 156
                            SiteUtility::getConnectionProperty($typo3Site, 'path', $languageUid, 'read', '/solr/') .
470 156
                            SiteUtility::getConnectionProperty($typo3Site, 'core', $languageUid, 'read', 'core_en') . '/' ,
471 156
                        'username' => SiteUtility::getConnectionProperty($typo3Site, 'username', $languageUid, 'read', ''),
472 156
                        'password' => SiteUtility::getConnectionProperty($typo3Site, 'password', $languageUid, 'read', ''),
473 156
                        'timeout' => SiteUtility::getConnectionProperty($typo3Site, 'timeout', $languageUid, 'read', 0)
474
                    ],
475
                    'write' => [
476 156
                        'scheme' => SiteUtility::getConnectionProperty($typo3Site, 'scheme', $languageUid, 'write', 'http'),
477 156
                        'host' => SiteUtility::getConnectionProperty($typo3Site, 'host', $languageUid, 'write', 'localhost'),
478 156
                        'port' => (int)SiteUtility::getConnectionProperty($typo3Site, 'port', $languageUid, 'write', 8983),
479
                        // @todo: transform core to path
480
                        'path' =>
481 156
                            SiteUtility::getConnectionProperty($typo3Site, 'path', $languageUid, 'read', '/solr/') .
482 156
                            SiteUtility::getConnectionProperty($typo3Site, 'core', $languageUid, 'read', 'core_en') . '/' ,
483 156
                        'username' => SiteUtility::getConnectionProperty($typo3Site, 'username', $languageUid, 'write', ''),
484 156
                        'password' => SiteUtility::getConnectionProperty($typo3Site, 'password', $languageUid, 'write', ''),
485 156
                        'timeout' => SiteUtility::getConnectionProperty($typo3Site, 'timeout', $languageUid, 'write', 0)
486
                    ],
487
488 156
                    'language' => $languageUid
489
                ];
490
            }
491
        }
492
493 156
        return GeneralUtility::makeInstance(
494 156
            Typo3ManagedSite::class,
495
            /** @scrutinizer ignore-type */
496 156
            $solrConfiguration,
497
            /** @scrutinizer ignore-type */
498 156
            $rootPageRecord,
499
            /** @scrutinizer ignore-type */
500 156
            $domain,
501
            /** @scrutinizer ignore-type */
502 156
            $siteHash,
503
            /** @scrutinizer ignore-type */
504 156
            $pageRepository,
505
            /** @scrutinizer ignore-type */
506 156
            $defaultLanguage,
507
            /** @scrutinizer ignore-type */
508 156
            $availableLanguageIds,
509
            /** @scrutinizer ignore-type */
510 156
            $solrConnectionConfigurations,
511
            /** @scrutinizer ignore-type */
512 156
            $typo3Site
513
        );
514
    }
515
516
}
517