[TASK] Move verbosity settings into TemplateService 81/57581/4
authorBenni Mack <benni@typo3.org>
Thu, 12 Jul 2018 18:13:45 +0000 (20:13 +0200)
committerBenni Mack <benni@typo3.org>
Fri, 13 Jul 2018 15:32:49 +0000 (17:32 +0200)
The constructor of TemplateService now has
a context, which knows everything to define
public settings to define if tt_track and verbose
should be set.

Resolves: #85542
Releases: master
Change-Id: I11306a57c64e8c5cb0d0a069b73e06f066b72d8e
Reviewed-on: https://review.typo3.org/57581
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/core/Classes/TypoScript/ConfigurationForm.php
typo3/sysext/core/Classes/TypoScript/ExtendedTemplateService.php
typo3/sysext/core/Classes/TypoScript/TemplateService.php
typo3/sysext/core/Tests/Unit/TypoScript/TemplateServiceTest.php
typo3/sysext/core/Tests/UnitDeprecated/TypoScript/TemplateServiceTest.php
typo3/sysext/extbase/Classes/Configuration/BackendConfigurationManager.php
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php

index f69a2f8..5c64224 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\TypoScript;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -53,13 +54,14 @@ class ConfigurationForm extends ExtendedTemplateService
     protected $ext_realValues = [];
 
     /**
-     * Deprecate this class
+     * @param Context|null $context
      */
-    public function __construct()
+    public function __construct(Context $context = null)
     {
+        parent::__construct($context);
+        // Deprecate this class
         trigger_error('Class ConfigurationForm has been deprecated with v9 and will be removed in v10', E_USER_DEPRECATED);
     }
-
     /**
      * @param string $configTemplate
      * @return array
index 5201730..a4e9694 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Core\TypoScript;
 
 use TYPO3\CMS\Backend\Template\DocumentTemplate;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
@@ -34,13 +35,6 @@ use TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatch
 class ExtendedTemplateService extends TemplateService
 {
     /**
-     * Disabled in backend context
-     *
-     * @var bool
-     */
-    public $tt_track = false;
-
-    /**
      * @var array
      */
     public $categories = [
@@ -242,6 +236,17 @@ class ExtendedTemplateService extends TemplateService
     protected $inlineJavaScript = [];
 
     /**
+     * @param Context|null $context
+     */
+    public function __construct(Context $context = null)
+    {
+        parent::__construct($context);
+        // Disabled in backend context
+        $this->tt_track = false;
+        $this->verbose = false;
+    }
+
+    /**
      * Gets the inline JavaScript.
      *
      * @return array
index b76b61d..0acbc24 100644 (file)
@@ -397,6 +397,8 @@ class TemplateService
                 $this->allowedPaths[] = $p;
             }
         }
+
+        $this->tt_track = $this->verbose = (bool)$this->context->getPropertyFromAspect('backend.user', 'isLoggedIn', false);
     }
 
     /**
index 0075d3e..0fd540d 100644 (file)
@@ -59,13 +59,11 @@ class TemplateServiceTest extends UnitTestCase
         $GLOBALS['SIM_ACCESS_TIME'] = time();
         $GLOBALS['ACCESS_TIME'] = time();
         $this->templateService = new TemplateService(new Context());
-        $this->templateService->tt_track = false;
         $this->templateServiceMock = $this->getAccessibleMock(
             TemplateService::class,
             ['dummy'],
             [new Context()]
         );
-        $this->templateServiceMock->tt_track = false;
         $this->backupPackageManager = ExtensionManagementUtilityAccessibleProxy::getPackageManager();
     }
 
index a5be928..8c1f49c 100644 (file)
@@ -36,7 +36,6 @@ class TemplateServiceTest extends UnitTestCase
     protected function setUp(): void
     {
         $this->templateService = new TemplateService(new Context());
-        $this->templateService->tt_track = false;
     }
 
     /**
index 7780a3b..7f48fb4 100644 (file)
@@ -55,7 +55,7 @@ class BackendConfigurationManager extends AbstractConfigurationManager
             /** @var $template TemplateService */
             $template = GeneralUtility::makeInstance(TemplateService::class);
             // do not log time-performance information
-            $template->tt_track = 0;
+            $template->tt_track = false;
             // Explicitly trigger processing of extension static files
             $template->setProcessExtensionStatics(true);
             // Get the root line
index c7e0c06..74c54a5 100644 (file)
@@ -2220,8 +2220,6 @@ class TypoScriptFrontendController implements LoggerAwareInterface
     public function initTemplate()
     {
         $this->tmpl = GeneralUtility::makeInstance(TemplateService::class, $this->context);
-        $this->tmpl->setVerbose($this->isBackendUserLoggedIn());
-        $this->tmpl->tt_track = $this->isBackendUserLoggedIn();
     }
 
     /**