Feature: #99802 - New PSR-14 ModifyRedirectManagementControllerViewDataEvent¶
See forge#99802
Description¶
A new PSR-14 event \TYPO3\CMS\Redirects\Event\ModifyRedirectManagementControllerViewDataEvent
is introduced, allowing extension authors to modify or enrich view data for the
\TYPO3\CMS\Redirects\Controller\ManagementController
. This allows to
display more or other information along the way.
This event features the following methods:
getDemand()
: Return the demand object used to retrieve the redirectsgetRedirects()
: Return the retrieved redirectssetRedirects()
: Can be used to set the redirects, for example, after enriching redirect fieldsgetRequest()
: Return the current requestgetHosts()
: Returns the hosts to be used for the host filter select-boxsetHosts()
: Can be used to update which hosts are available in the filter select-boxgetStatusCodes()
: Returns the status codes for the filter select boxsetStatusCodes()
: Can be used to update which status codes are available in the filter select-boxgetCreationTypes()
: Returns creation types for the filter select boxsetCreationTypes()
: Can be used to update which creation types are available in the filter select-boxgetShowHitCounter()
: Returns if hit counter should be displayedsetShowHitCounter()
: Can be used to manage if the hit counter should be displayedgetView()
: Returns the current view object, without controller data assigned yetsetView()
: Can be used to assign additional data to the view
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 ModifyRedirectManagementControllerViewDataEvent
, it is
now possible to modify view data or inject further data to the view for the
management view of redirects.