[TASK] Move domainStartPage setting to PageResolver 09/58009/2
authorBenni Mack <benni@typo3.org>
Thu, 23 Aug 2018 16:41:40 +0000 (18:41 +0200)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Thu, 23 Aug 2018 17:03:55 +0000 (19:03 +0200)
The setting of the domainStartPage has been simplified with the PseudoSite
introduction, and, as it belongs to the enriching of the PageResolver,
the functionality is moved from the SiteResolver to the PageResolver.

Resolves: #85951
Releases: master
Change-Id: I67f88c1b6369450f63b582be1205a8639217304e
Reviewed-on: https://review.typo3.org/58009
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
typo3/sysext/frontend/Classes/Middleware/PageResolver.php
typo3/sysext/frontend/Classes/Middleware/SiteResolver.php
typo3/sysext/frontend/Tests/Unit/Middleware/SiteResolverTest.php

index 6fd6a8b..5bf5ee1 100644 (file)
@@ -23,6 +23,7 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Context\UserAspect;
 use TYPO3\CMS\Core\Context\WorkspaceAspect;
+use TYPO3\CMS\Core\Site\Entity\SiteInterface;
 use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
@@ -45,6 +46,11 @@ class PageResolver implements MiddlewareInterface
      */
     public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
     {
+        // First, resolve the root page of the site, the Page ID of the current domain
+        if (($site = $request->getAttribute('site', null)) instanceof SiteInterface) {
+            $GLOBALS['TSFE']->domainStartPage = $site->getRootPageId();
+        }
+
         $GLOBALS['TSFE']->siteScript = $request->getAttribute('normalizedParams')->getSiteScript();
         $this->checkAlternativeIdMethods($GLOBALS['TSFE']);
         $GLOBALS['TSFE']->determineId();
index 4e4ca4d..5a3608a 100644 (file)
@@ -23,7 +23,6 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Routing\SiteMatcher;
 use TYPO3\CMS\Core\Site\Entity\PseudoSite;
 use TYPO3\CMS\Core\Site\Entity\Site;
-use TYPO3\CMS\Core\Site\Entity\SiteInterface;
 use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
 use TYPO3\CMS\Core\Site\SiteFinder;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -96,11 +95,6 @@ class SiteResolver implements MiddlewareInterface
             $GLOBALS['TYPO3_REQUEST'] = $request;
         }
 
-        // Now resolve the root page of the site, the page_id of the current domain
-        if ($site instanceof SiteInterface) {
-            $GLOBALS['TSFE']->domainStartPage = $site->getRootPageId();
-        }
-
         return $handler->handle($request);
     }
 
index 4876916..ce7e4e1 100644 (file)
@@ -52,8 +52,6 @@ class SiteResolverTest extends UnitTestCase
      */
     protected function setUp(): void
     {
-        // Make global object available, however it is not actively used
-        $GLOBALS['TSFE'] = new \stdClass();
         $this->siteFinder = $this->getAccessibleMock(SiteFinder::class, ['dummy'], [], '', false);
 
         // A request handler which expects a site to be found.
@@ -70,7 +68,7 @@ class SiteResolverTest extends UnitTestCase
                             'site' => $site->getIdentifier(),
                             'language-id' => $language->getLanguageId(),
                             'language-base' => $language->getBase(),
-                            'rootpage' => $GLOBALS['TSFE']->domainStartPage
+                            'rootpage' => $site->getRootPageId()
                         ]
                     );
                 }