[TASK] Split site configuration loading into separate method 62/57862/2
authorBenni Mack <benni@typo3.org>
Fri, 10 Aug 2018 18:29:19 +0000 (20:29 +0200)
committerFrank Naegler <frank.naegler@typo3.org>
Fri, 10 Aug 2018 19:05:38 +0000 (21:05 +0200)
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>
typo3/sysext/core/Classes/Configuration/SiteConfiguration.php

index 4fad0d1..87987c1 100644 (file)
@@ -70,6 +70,25 @@ class SiteConfiguration
      */
     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)) {
             $siteConfiguration = json_decode($siteConfiguration, true);
@@ -93,14 +112,7 @@ class SiteConfiguration
             }
             $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 ?? [];
     }
 
     /**