[TASK] Prepare Site handling for extended page routing 19/58419/4
authorBenni Mack <benni@typo3.org>
Thu, 27 Sep 2018 20:05:35 +0000 (22:05 +0200)
committerBenni Mack <benni@typo3.org>
Thu, 27 Sep 2018 20:33:00 +0000 (22:33 +0200)
An additional trait for site languages and some minor simplifications
when fetching the PageRouter from a Site.

Resolves: #86410
Releases: master
Change-Id: I88fd8fccbd19aada7014e7dca04c964e87fdd0cd
Reviewed-on: https://review.typo3.org/58419
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
typo3/sysext/core/Classes/Routing/PageRouter.php
typo3/sysext/core/Classes/Site/Entity/Site.php
typo3/sysext/core/Classes/Site/SiteLanguageAwareTrait.php [new file with mode: 0644]

index 305a1d8..d9d9a84 100644 (file)
@@ -66,20 +66,13 @@ class PageRouter implements RouterInterface
     protected $site;
 
     /**
-     * @var array
-     */
-    protected $configuration;
-
-    /**
      * A page router is always bound to a specific site.
      *
      * @param Site $site
-     * @param array $configuration
      */
-    public function __construct(Site $site, array $configuration)
+    public function __construct(Site $site)
     {
         $this->site = $site;
-        $this->configuration = $configuration;
     }
 
     /**
index a0feab8..86e58b3 100644 (file)
@@ -343,7 +343,7 @@ class Site implements SiteInterface
      */
     public function getRouter(): RouterInterface
     {
-        return new PageRouter($this, $this->configuration['routing'] ?? []);
+        return GeneralUtility::makeInstance(PageRouter::class, $this);
     }
 
     /**
diff --git a/typo3/sysext/core/Classes/Site/SiteLanguageAwareTrait.php b/typo3/sysext/core/Classes/Site/SiteLanguageAwareTrait.php
new file mode 100644 (file)
index 0000000..86ce225
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+declare(strict_types = 1);
+
+namespace TYPO3\CMS\Core\Site;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * Helper trait to use a site language within a class.
+ *
+ * @internal this is not public API yet as this might change, and could be changed within TYPO3 Core at any time.
+ */
+trait SiteLanguageAwareTrait
+{
+    /**
+     * @var Entity\SiteLanguage
+     */
+    protected $siteLanguage;
+
+    /**
+     * @param Entity\SiteLanguage $siteLanguage
+     */
+    public function setSiteLanguage(Entity\SiteLanguage $siteLanguage)
+    {
+        $this->siteLanguage = $siteLanguage;
+    }
+
+    /**
+     * @return Entity\SiteLanguage
+     */
+    public function getSiteLanguage(): Entity\SiteLanguage
+    {
+        return $this->siteLanguage;
+    }
+}