‪TYPO3CMS  ‪main
PageTitle.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;
27 
34 {
38  protected const ‪LOG_COMPONENT = 'TYPO3.CMS.Core.PageTitle.PageTitleProviderManager';
39 
44  public function ‪getIdentifier(): string
45  {
46  return 'debug_pagetitle';
47  }
48 
52  public function ‪getLabel(): string
53  {
54  return $this->‪getLanguageService()->sL(
55  'LLL:EXT:adminpanel/Resources/Private/Language/locallang_debug.xlf:submodule.pageTitle.label'
56  );
57  }
58 
59  public function ‪getDataToStore(ServerRequestInterface $request): ‪ModuleData
60  {
61  $data = [
62  'cacheEnabled' => true,
63  ];
64  if (!$this->‪isCachingAllowed($request)) {
65  $data = [
66  'orderedProviders' => [],
67  'usedProvider' => null,
68  'skippedProviders' => [],
69  ];
70  $logRecords = GeneralUtility::makeInstance(InMemoryLogWriter::class)->getLogEntries();
71  foreach ($logRecords as $logEntry) {
72  if ($logEntry->getComponent() === self::LOG_COMPONENT) {
73  $logEntryData = $logEntry->getData();
74  if (isset($logEntryData['orderedTitleProviders'])) {
75  $data['orderedProviders'] = $logEntryData['orderedTitleProviders'];
76  } elseif (isset($logEntryData['providerUsed'])) {
77  $data['usedProvider'] = $logEntryData;
78  } elseif (isset($logEntry->getData()['skippedProvider'])) {
79  $data['skippedProviders'][] = $logEntryData;
80  }
81  }
82  }
83  }
84  return new ‪ModuleData($data);
85  }
86 
90  public function ‪getContent(‪ModuleData $data): string
91  {
92  $view = new ‪StandaloneView();
93  $view->setTemplatePathAndFilename(
94  'EXT:adminpanel/Resources/Private/Templates/Modules/Debug/PageTitle.html'
95  );
96  $view->assignMultiple($data->getArrayCopy());
97  $view->assign('languageKey', $this->‪getBackendUser()->user['lang'] ?? null);
98  return $view->render();
99  }
100 
101  protected function ‪isCachingAllowed(ServerRequestInterface $request): bool
102  {
103  return $request->getAttribute('frontend.cache.instruction')->isCachingAllowed();
104  }
105 }
‪TYPO3\CMS\Adminpanel\ModuleApi\DataProviderInterface
Definition: DataProviderInterface.php:30
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractSubModule\getBackendUser
‪getBackendUser()
Definition: AbstractSubModule.php:35
‪TYPO3\CMS\Adminpanel\Modules\Debug
Definition: Events.php:18
‪TYPO3\CMS\Adminpanel\Modules\Debug\PageTitle\getIdentifier
‪getIdentifier()
Definition: PageTitle.php:44
‪TYPO3\CMS\Adminpanel\Modules\Debug\PageTitle\isCachingAllowed
‪isCachingAllowed(ServerRequestInterface $request)
Definition: PageTitle.php:101
‪TYPO3\CMS\Adminpanel\Modules\Debug\PageTitle\getDataToStore
‪getDataToStore(ServerRequestInterface $request)
Definition: PageTitle.php:59
‪TYPO3\CMS\Adminpanel\Log\InMemoryLogWriter
Definition: InMemoryLogWriter.php:38
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:30
‪TYPO3\CMS\Adminpanel\Modules\Debug\PageTitle
Definition: PageTitle.php:34
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractSubModule\getLanguageService
‪getLanguageService()
Definition: AbstractSubModule.php:30
‪TYPO3\CMS\Adminpanel\Modules\Debug\PageTitle\getLabel
‪getLabel()
Definition: PageTitle.php:52
‪TYPO3\CMS\Adminpanel\Modules\Debug\PageTitle\LOG_COMPONENT
‪const LOG_COMPONENT
Definition: PageTitle.php:38
‪TYPO3\CMS\Adminpanel\ModuleApi\ModuleData
Definition: ModuleData.php:26
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Adminpanel\Modules\Debug\PageTitle\getContent
‪string getContent(ModuleData $data)
Definition: PageTitle.php:90
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractSubModule
Definition: AbstractSubModule.php:29