‪TYPO3CMS  ‪main
WarningsForAboutModule.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 
27 
34 {
35  private string ‪$reportsModuleName = 'system_reports';
36 
37  public function ‪__construct(
38  private readonly ‪Registry $registry,
39  private readonly ‪Context $context
40  ) {}
41 
48  #[AsEventListener('typo3-reports/warnings')]
49  public function ‪__invoke(‪ModifyGenericBackendMessagesEvent $event): void
50  {
51  if (!$this->context->getAspect('backend.user')->isAdmin()) {
52  return;
53  }
54  // Get the highest severity
55  $highestSeverity = $this->registry->get('tx_reports', 'status.highestSeverity');
56  if ($highestSeverity === null || $highestSeverity <= ContextualFeedbackSeverity::OK->value) {
57  return;
58  }
59  // Display a message that there's something wrong and that
60  // the administrator should take a look at the detailed status report
61  $event->‪addMessage(new ‪FlashMessage(sprintf(
62  $this->‪getLanguageService()->sL('LLL:EXT:reports/Resources/Private/Language/locallang_reports.xlf:status_problemNotification'),
63  '<a href="#" data-dispatch-action="TYPO3.ModuleMenu.showModule" '
64  . 'data-dispatch-args-list="' . $this->reportsModuleName . '">',
65  '</a>'
66  )));
67  }
68 
70  {
71  return ‪$GLOBALS['LANG'];
72  }
73 }
‪TYPO3\CMS\Reports\Report\WarningsForAboutModule
Definition: WarningsForAboutModule.php:34
‪TYPO3\CMS\Reports\Report
‪TYPO3\CMS\Core\Attribute\AsEventListener
Definition: AsEventListener.php:25
‪TYPO3\CMS\Core\Registry
Definition: Registry.php:33
‪TYPO3\CMS\Core\Context\Context
Definition: Context.php:54
‪TYPO3\CMS\Reports\Report\WarningsForAboutModule\getLanguageService
‪getLanguageService()
Definition: WarningsForAboutModule.php:69
‪TYPO3\CMS\Backend\Controller\Event\ModifyGenericBackendMessagesEvent
Definition: ModifyGenericBackendMessagesEvent.php:26
‪TYPO3\CMS\Core\Type\ContextualFeedbackSeverity
‪ContextualFeedbackSeverity
Definition: ContextualFeedbackSeverity.php:25
‪TYPO3\CMS\Reports\Report\WarningsForAboutModule\__construct
‪__construct(private readonly Registry $registry, private readonly Context $context)
Definition: WarningsForAboutModule.php:37
‪TYPO3\CMS\Reports\Report\WarningsForAboutModule\$reportsModuleName
‪string $reportsModuleName
Definition: WarningsForAboutModule.php:35
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:27
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Backend\Controller\Event\ModifyGenericBackendMessagesEvent\addMessage
‪addMessage(AbstractMessage $message)
Definition: ModifyGenericBackendMessagesEvent.php:34
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Reports\Report\WarningsForAboutModule\__invoke
‪__invoke(ModifyGenericBackendMessagesEvent $event)
Definition: WarningsForAboutModule.php:49