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