‪TYPO3CMS  ‪main
Events.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\EventDispatcher\EventDispatcherInterface;
21 use Psr\Http\Message\ServerRequestInterface;
22 use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
23 use Symfony\Component\VarDumper\Cloner\Data;
24 use Symfony\Component\VarDumper\Cloner\VarCloner;
25 use Symfony\Component\VarDumper\Dumper\AbstractDumper;
33 
37 #[Autoconfigure(public: true)]
39 {
40  public function ‪__construct(private readonly ‪RequestId $requestId) {}
41 
42  public function ‪getIdentifier(): string
43  {
44  return 'debug_events';
45  }
46 
47  public function ‪getLabel(): string
48  {
49  return $this->‪getLanguageService()->sL(
50  'LLL:EXT:adminpanel/Resources/Private/Language/locallang_debug.xlf:submodule.events.label'
51  );
52  }
53 
54  public function ‪getDataToStore(ServerRequestInterface $request): ‪ModuleData
55  {
57  $eventDispatcher = GeneralUtility::makeInstance(EventDispatcherInterface::class);
58  $cloner = new VarCloner();
59  $cloner->setMinDepth(2);
60  $cloner->setMaxItems(10);
61  return new ‪ModuleData(
62  [
63  'events' => $cloner->cloneVar($eventDispatcher->getDispatchedEvents()),
64  ]
65  );
66  }
67 
68  public function ‪getContent(‪ModuleData $data): string
69  {
70  $view = GeneralUtility::makeInstance(StandaloneView::class);
71  $templateNameAndPath = 'EXT:adminpanel/Resources/Private/Templates/Modules/Debug/Events.html';
72  $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templateNameAndPath));
73  $view->setPartialRootPaths(['EXT:adminpanel/Resources/Private/Partials']);
74  $values = $data->getArrayCopy();
75  $events = $values['events'] ?? null;
76 
77  $dumper = new ‪HtmlDumper(null, null, AbstractDumper::DUMP_LIGHT_ARRAY);
78  $dumper->setNonce($this->requestId->nonce);
79  $dumper->setTheme('light');
80 
81  $view->assign('events', $events instanceof Data ? $dumper->dump($events, true) : null);
82  $view->assign('languageKey', $this->‪getBackendUser()->user['lang'] ?? null);
83 
84  return $view->render();
85  }
86 }
‪TYPO3\CMS\Adminpanel\Modules\Debug\Events\__construct
‪__construct(private readonly RequestId $requestId)
Definition: Events.php:40
‪TYPO3\CMS\Adminpanel\ModuleApi\DataProviderInterface
Definition: DataProviderInterface.php:30
‪TYPO3\CMS\Adminpanel\Modules\Debug\Events
Definition: Events.php:39
‪TYPO3\CMS\Adminpanel\Modules\Debug\Events\getIdentifier
‪getIdentifier()
Definition: Events.php:42
‪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\Events\getLabel
‪getLabel()
Definition: Events.php:47
‪TYPO3\CMS\Core\Core\RequestId
Definition: RequestId.php:26
‪TYPO3\CMS\Adminpanel\Utility\HtmlDumper
Definition: HtmlDumper.php:30
‪TYPO3\CMS\Adminpanel\Modules\Debug\Events\getDataToStore
‪getDataToStore(ServerRequestInterface $request)
Definition: Events.php:54
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:30
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractSubModule\getLanguageService
‪getLanguageService()
Definition: AbstractSubModule.php:30
‪TYPO3\CMS\Adminpanel\ModuleApi\ModuleData
Definition: ModuleData.php:26
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractSubModule
Definition: AbstractSubModule.php:29
‪TYPO3\CMS\Adminpanel\Modules\Debug\Events\getContent
‪getContent(ModuleData $data)
Definition: Events.php:68