Skip to content

Commit

Permalink
[TASK] Split site configuration loading into separate method
Browse files Browse the repository at this point in the history
Resolves: #85810
Releases: master
Change-Id: I329b343715895536fde5013b2ece9e2717c3834d
Reviewed-on: https://review.typo3.org/57862
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
  • Loading branch information
bmack authored and NeoBlack committed Aug 10, 2018
1 parent 51222a8 commit ba830f0
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions typo3/sysext/core/Classes/Configuration/SiteConfiguration.php
Expand Up @@ -69,6 +69,25 @@ public function __construct(string $configPath)
* @return Site[]
*/
public function resolveAllExistingSites(): array
{
$sites = [];
$siteConfiguration = $this->getAllSiteConfigurationFromFiles();
foreach ($siteConfiguration as $identifier => $configuration) {
$rootPageId = (int)($configuration['site']['rootPageId'] ?? 0);
if ($rootPageId > 0) {
$sites[$identifier] = GeneralUtility::makeInstance(Site::class, $identifier, $rootPageId, $configuration['site']);
}
}
return $sites;
}

/**
* Read the site configuration from config files.
*
* @return array
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
*/
protected function getAllSiteConfigurationFromFiles(): array
{
// Check if the data is already cached
if ($siteConfiguration = $this->getCache()->get($this->cacheIdentifier)) {
Expand All @@ -93,14 +112,7 @@ public function resolveAllExistingSites(): array
}
$this->getCache()->set($this->cacheIdentifier, json_encode($siteConfiguration));
}
$sites = [];
foreach ($siteConfiguration ?? [] as $identifier => $configuration) {
$rootPageId = (int)($configuration['site']['rootPageId'] ?? 0);
if ($rootPageId > 0) {
$sites[$identifier] = GeneralUtility::makeInstance(Site::class, $identifier, $rootPageId, $configuration['site']);
}
}
return $sites;
return $siteConfiguration ?? [];
}

/**
Expand Down

0 comments on commit ba830f0

Please sign in to comment.