‪TYPO3CMS  9.5
TypoScriptWaterfall.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
19 use Psr\Http\Message\ServerRequestInterface;
31 
38 {
42  protected ‪$configurationService;
43 
44  public function ‪__construct()
45  {
46  $this->configurationService = GeneralUtility::makeInstance(ConfigurationService::class);
47  }
48 
52  public function ‪getIdentifier(): string
53  {
54  return 'typoscript-waterfall';
55  }
56 
60  public function ‪getLabel(): string
61  {
62  return $this->‪getLanguageService()->‪sL(
63  'LLL:EXT:adminpanel/Resources/Private/Language/locallang_tsdebug.xlf:sub.waterfall.label'
64  );
65  }
66 
70  public function ‪initializeModule(ServerRequestInterface $request): void
71  {
72  $typoScriptFrontend = $this->‪getTypoScriptFrontendController();
73  $typoScriptFrontend->forceTemplateParsing = $this->‪getConfigurationOption(
74  'forceTemplateParsing'
75  );
76  if ($typoScriptFrontend->forceTemplateParsing) {
77  $typoScriptFrontend->set_no_cache('Admin Panel: Force template parsing', true);
78  }
79  $this->‪getTimeTracker()->LR = (bool)$this->‪getConfigurationOption('LR');
80  }
81 
88  public function ‪getContent(ModuleData $data): string
89  {
90  $view = GeneralUtility::makeInstance(StandaloneView::class);
91  $templateNameAndPath = 'EXT:adminpanel/Resources/Private/Templates/Modules/TsDebug/TypoScript.html';
92  $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templateNameAndPath));
93  $view->setPartialRootPaths(['EXT:adminpanel/Resources/Private/Partials']);
94 
95  $view->assignMultiple(
96  [
97  'tree' => (int)$this->‪getConfigurationOption('tree'),
98  'display' => [
99  'times' => (int)$this->‪getConfigurationOption('displayTimes'),
100  'messages' => (int)$this->‪getConfigurationOption('displayMessages'),
101  'content' => (int)$this->‪getConfigurationOption('displayContent'),
102  ],
103  'trackContentRendering' => (int)$this->‪getConfigurationOption('LR'),
104  'forceTemplateParsing' => (int)$this->‪getConfigurationOption('forceTemplateParsing'),
105  'typoScriptLog' => $this->‪renderTypoScriptLog(),
106  ]
107  );
108 
109  return $view->render();
110  }
111 
115  public function ‪getSettings(): string
116  {
117  $view = GeneralUtility::makeInstance(StandaloneView::class);
118  $templateNameAndPath = 'EXT:adminpanel/Resources/Private/Templates/Modules/TsDebug/TypoScriptSettings.html';
119  $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templateNameAndPath));
120  $view->setPartialRootPaths(['EXT:adminpanel/Resources/Private/Partials']);
121 
122  $view->assignMultiple(
123  [
124  'tree' => (int)$this->‪getConfigurationOption('tree'),
125  'display' => [
126  'times' => (int)$this->‪getConfigurationOption('displayTimes'),
127  'messages' => (int)$this->‪getConfigurationOption('displayMessages'),
128  'content' => (int)$this->‪getConfigurationOption('displayContent'),
129  ],
130  'trackContentRendering' => (int)$this->‪getConfigurationOption('LR'),
131  'forceTemplateParsing' => (int)$this->‪getConfigurationOption('forceTemplateParsing')
132  ]
133  );
134 
135  return $view->render();
136  }
137 
143  protected function ‪getBackendUser(): BackendUserAuthentication
144  {
145  return ‪$GLOBALS['BE_USER'];
146  }
147 
152  protected function ‪getConfigurationOption(string $option): bool
153  {
154  return (bool)$this->configurationService->getConfigurationOption('tsdebug', $option);
155  }
156 
162  protected function ‪renderTypoScriptLog(): string
163  {
164  $timeTracker = $this->‪getTimeTracker();
165  $timeTracker->printConf['flag_tree'] = $this->‪getConfigurationOption('tree');
166  $timeTracker->printConf['allTime'] = $this->‪getConfigurationOption(
167  'displayTimes'
168  );
169  $timeTracker->printConf['flag_messages'] = $this->‪getConfigurationOption(
170  'displayMessages'
171  );
172  $timeTracker->printConf['flag_content'] = $this->‪getConfigurationOption(
173  'displayContent'
174  );
175  return $timeTracker->printTSlog();
176  }
177 
181  protected function ‪getTimeTracker(): TimeTracker
182  {
183  return GeneralUtility::makeInstance(TimeTracker::class);
184  }
185 
189  protected function ‪getTypoScriptFrontendController(): TypoScriptFrontendController
190  {
191  return ‪$GLOBALS['TSFE'];
192  }
193 }
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\getBackendUser
‪BackendUserAuthentication FrontendBackendUserAuthentication getBackendUser()
Definition: TypoScriptWaterfall.php:142
‪TYPO3\CMS\Adminpanel\Modules\TsDebug
Definition: TypoScriptWaterfall.php:4
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall
Definition: TypoScriptWaterfall.php:38
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\__construct
‪__construct()
Definition: TypoScriptWaterfall.php:43
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\$configurationService
‪ConfigurationService $configurationService
Definition: TypoScriptWaterfall.php:41
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractSubModule\getLanguageService
‪LanguageService getLanguageService()
Definition: AbstractSubModule.php:33
‪TYPO3\CMS\Backend\FrontendBackendUserAuthentication
Definition: FrontendBackendUserAuthentication.php:35
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\getIdentifier
‪getIdentifier()
Definition: TypoScriptWaterfall.php:51
‪TYPO3\CMS\Adminpanel\ModuleApi\InitializableInterface
Definition: InitializableInterface.php:34
‪TYPO3\CMS\Core\Localization\LanguageService\sL
‪string sL($input)
Definition: LanguageService.php:158
‪TYPO3\CMS\Adminpanel\ModuleApi\ModuleSettingsProviderInterface
Definition: ModuleSettingsProviderInterface.php:33
‪TYPO3\CMS\Adminpanel\Service\ConfigurationService
Definition: ConfigurationService.php:33
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:45
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\getConfigurationOption
‪bool getConfigurationOption(string $option)
Definition: TypoScriptWaterfall.php:151
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\renderTypoScriptLog
‪string renderTypoScriptLog()
Definition: TypoScriptWaterfall.php:161
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\getContent
‪string getContent(ModuleData $data)
Definition: TypoScriptWaterfall.php:87
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:32
‪TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
Definition: TypoScriptFrontendController.php:97
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\getLabel
‪getLabel()
Definition: TypoScriptWaterfall.php:59
‪TYPO3\CMS\Adminpanel\ModuleApi\ModuleData
Definition: ModuleData.php:26
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\initializeModule
‪initializeModule(ServerRequestInterface $request)
Definition: TypoScriptWaterfall.php:69
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\TimeTracker\TimeTracker
Definition: TimeTracker.php:27
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\getTimeTracker
‪TimeTracker getTimeTracker()
Definition: TypoScriptWaterfall.php:180
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractSubModule
Definition: AbstractSubModule.php:27
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\getTypoScriptFrontendController
‪TypoScriptFrontendController getTypoScriptFrontendController()
Definition: TypoScriptWaterfall.php:188
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\getSettings
‪getSettings()
Definition: TypoScriptWaterfall.php:114