ModifyGenericBackendMessagesEvent
New in version 12.0
This event serves as direct replacement for the now removed hook
$GLOBALS
.
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).
Extensions such as the EXT:reports system extension use this event to display custom messages based on the system status:
Example
Registration of an event listener in your extension's Services.
:
services:
# Place here the default dependency injection configuration
MyVendor\MyExtension\Backend\EventListener\MyEventListener:
tags:
- name: event.listener
identifier: 'my-extension/backend/add-message'
Read how to configure dependency injection in extensions.
The corresponding event listener class:
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Backend\EventListener;
use TYPO3\CMS\Backend\Controller\Event\ModifyGenericBackendMessagesEvent;
use TYPO3\CMS\Core\Messaging\FlashMessage;
final class MyEventListener
{
public function __invoke(ModifyGenericBackendMessagesEvent $event): void
{
// Add a custom message
$event->addMessage(new FlashMessage('My custom message'));
}
}