ModifyGenericBackendMessagesEvent
The PSR-14 event
\TYPO3\
allows to add or alter messages that are displayed in the About
module (default start module of the TYPO3 backend).
Changed in version 14.3 Important: #109493 - Messages in the About module respect their severity
Before, the module rendered every message as an error infobox. A message created without a severity now renders as a green "OK" infobox.
The module renders each message with the severity of its
\TYPO3\. The severity defaults to
\TYPO3\, so state the
severity of the message explicitly.
Extensions such as the EXT:reports system extension use this event to display custom messages based on the system status:
A generic backend message in the about module
Example: Announce a planned maintenance in the About module
The following listener shows a warning about a planned maintenance to every backend user who opens the About module:
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Backend\EventListener;
use TYPO3\CMS\Backend\Controller\Event\ModifyGenericBackendMessagesEvent;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
#[AsEventListener(
identifier: 'my-extension/maintenance-warning',
)]
final readonly class MaintenanceWarningListener
{
public function __invoke(ModifyGenericBackendMessagesEvent $event): void
{
$event->addMessage(new FlashMessage(
'The site is in maintenance on Saturday from 8 to 10 am.',
'Planned maintenance',
ContextualFeedbackSeverity::WARNING,
));
}
}