‪TYPO3CMS  10.4
TypoScriptWaterfall.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\Http\Message\ServerRequestInterface;
33 
40 {
44  protected ‪$configurationService;
45 
46  public function ‪__construct()
47  {
48  $this->configurationService = GeneralUtility::makeInstance(ConfigurationService::class);
49  }
50 
54  public function ‪getIdentifier(): string
55  {
56  return 'typoscript-waterfall';
57  }
58 
62  public function ‪getLabel(): string
63  {
64  return $this->‪getLanguageService()->‪sL(
65  'LLL:EXT:adminpanel/Resources/Private/Language/locallang_tsdebug.xlf:sub.waterfall.label'
66  );
67  }
68 
72  public function ‪enrich(ServerRequestInterface $request): ServerRequestInterface
73  {
74  if ($this->‪getConfigurationOption('forceTemplateParsing')) {
75  GeneralUtility::makeInstance(Context::class)->setAspect('typoscript', GeneralUtility::makeInstance(TypoScriptAspect::class, true));
76  $request = $request->withAttribute('noCache', true);
77  }
78  $this->‪getTimeTracker()->LR = (bool)$this->‪getConfigurationOption('LR');
79  return $request;
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  'languageKey' => $this->‪getBackendUser()->user['lang'],
107  ]
108  );
109 
110  return $view->render();
111  }
112 
116  public function ‪getSettings(): string
117  {
118  $view = GeneralUtility::makeInstance(StandaloneView::class);
119  $templateNameAndPath = 'EXT:adminpanel/Resources/Private/Templates/Modules/TsDebug/TypoScriptSettings.html';
120  $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templateNameAndPath));
121  $view->setPartialRootPaths(['EXT:adminpanel/Resources/Private/Partials']);
122 
123  $view->assignMultiple(
124  [
125  'tree' => (int)$this->‪getConfigurationOption('tree'),
126  'display' => [
127  'times' => (int)$this->‪getConfigurationOption('displayTimes'),
128  'messages' => (int)$this->‪getConfigurationOption('displayMessages'),
129  'content' => (int)$this->‪getConfigurationOption('displayContent'),
130  ],
131  'trackContentRendering' => (int)$this->‪getConfigurationOption('LR'),
132  'forceTemplateParsing' => (int)$this->‪getConfigurationOption('forceTemplateParsing'),
133  'languageKey' => $this->‪getBackendUser()->user['lang'],
134  ]
135  );
136 
137  return $view->render();
138  }
139 
145  protected function ‪getBackendUser(): BackendUserAuthentication
146  {
147  return ‪$GLOBALS['BE_USER'];
148  }
149 
154  protected function ‪getConfigurationOption(string $option): bool
155  {
156  return (bool)$this->configurationService->getConfigurationOption('tsdebug', $option);
157  }
158 
164  protected function ‪renderTypoScriptLog(): string
165  {
166  $timeTracker = $this->‪getTimeTracker();
167  $timeTracker->printConf['flag_tree'] = $this->‪getConfigurationOption('tree');
168  $timeTracker->printConf['allTime'] = $this->‪getConfigurationOption(
169  'displayTimes'
170  );
171  $timeTracker->printConf['flag_messages'] = $this->‪getConfigurationOption(
172  'displayMessages'
173  );
174  $timeTracker->printConf['flag_content'] = $this->‪getConfigurationOption(
175  'displayContent'
176  );
177  return $timeTracker->printTSlog();
178  }
179 
183  protected function ‪getTimeTracker(): TimeTracker
184  {
185  return GeneralUtility::makeInstance(TimeTracker::class);
186  }
187 }
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\getBackendUser
‪BackendUserAuthentication FrontendBackendUserAuthentication getBackendUser()
Definition: TypoScriptWaterfall.php:144
‪TYPO3\CMS\Adminpanel\Modules\TsDebug
Definition: TypoScriptWaterfall.php:18
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall
Definition: TypoScriptWaterfall.php:40
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\__construct
‪__construct()
Definition: TypoScriptWaterfall.php:45
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\$configurationService
‪ConfigurationService $configurationService
Definition: TypoScriptWaterfall.php:43
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractSubModule\getLanguageService
‪LanguageService getLanguageService()
Definition: AbstractSubModule.php:35
‪TYPO3\CMS\Backend\FrontendBackendUserAuthentication
Definition: FrontendBackendUserAuthentication.php:31
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\getIdentifier
‪getIdentifier()
Definition: TypoScriptWaterfall.php:53
‪TYPO3\CMS\Core\Localization\LanguageService\sL
‪string sL($input)
Definition: LanguageService.php:194
‪TYPO3\CMS\Core\Context\Context
Definition: Context.php:53
‪TYPO3\CMS\Adminpanel\ModuleApi\ModuleSettingsProviderInterface
Definition: ModuleSettingsProviderInterface.php:34
‪TYPO3\CMS\Core\Context\TypoScriptAspect
Definition: TypoScriptAspect.php:29
‪TYPO3\CMS\Adminpanel\Service\ConfigurationService
Definition: ConfigurationService.php:34
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\getConfigurationOption
‪bool getConfigurationOption(string $option)
Definition: TypoScriptWaterfall.php:153
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\renderTypoScriptLog
‪string renderTypoScriptLog()
Definition: TypoScriptWaterfall.php:163
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\getContent
‪string getContent(ModuleData $data)
Definition: TypoScriptWaterfall.php:87
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:34
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\getLabel
‪getLabel()
Definition: TypoScriptWaterfall.php:61
‪TYPO3\CMS\Adminpanel\ModuleApi\ModuleData
Definition: ModuleData.php:27
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\TimeTracker\TimeTracker
Definition: TimeTracker.php:30
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\enrich
‪enrich(ServerRequestInterface $request)
Definition: TypoScriptWaterfall.php:71
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\getTimeTracker
‪TimeTracker getTimeTracker()
Definition: TypoScriptWaterfall.php:182
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractSubModule
Definition: AbstractSubModule.php:29
‪TYPO3\CMS\Adminpanel\Modules\TsDebug\TypoScriptWaterfall\getSettings
‪getSettings()
Definition: TypoScriptWaterfall.php:115
‪TYPO3\CMS\Adminpanel\ModuleApi\RequestEnricherInterface
Definition: RequestEnricherInterface.php:37