Feature: #99802 - New PSR-14 ModifyRedirectManagementControllerViewDataEvent
See forge#99802
Description
A new PSR-14 event
\TYPO3\
is introduced, allowing extension authors to modify or enrich view data for the
\TYPO3\
. This allows to
display more or other information along the way.
This event features the following methods:
get
: Return the demand object used to retrieve the redirectsDemand () get
: Return the retrieved redirectsRedirects () set
: Can be used to set the redirects, for example, after enriching redirect fieldsRedirects () get
: Return the current requestRequest () get
: Returns the hosts to be used for the host filter select-boxHosts () set
: Can be used to update which hosts are available in the filter select-boxHosts () get
: Returns the status codes for the filter select boxStatus Codes () set
: Can be used to update which status codes are available in the filter select-boxStatus Codes () get
: Returns creation types for the filter select boxCreation Types () set
: Can be used to update which creation types are available in the filter select-boxCreation Types () get
: Returns if hit counter should be displayedShow Hit Counter () set
: Can be used to manage if the hit counter should be displayedShow Hit Counter () get
: Returns the current view object, without controller data assigned yetView () set
: Can be used to assign additional data to the viewView ()
For example, this event can be used to add additional information to current page records.
Therefore, it can be used to generate custom data, directly assigning to the view. With overriding the backend view template via page TSconfig this custom data can be displayed where it is needed, and rendered the way it is wanted.
Example:
Registration of the event listener:
MyVendor\MyExtension\Redirects\MyEventListener:
tags:
- name: event.listener
identifier: 'my-extension/modify-redirect-management-controller-view-data'
The corresponding event listener class:
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Redirects;
use TYPO3\CMS\Redirects\Event\ModifyRedirectManagementControllerViewDataEvent;
final class MyEventListener {
public function __invoke(
ModifyRedirectManagementControllerViewDataEvent $event
): void {
$hosts = $event->getHosts();
// remove wildcard host from list
$hosts = array_filter($hosts, static fn ($host) => $host['name'] !== '*');
// update changed hosts list
$event->setHosts($hosts);
}
}
Impact
With the new
Modify
, it is
now possible to modify view data or inject further data to the view for the
management view of redirects.