ModifyRedirectManagementControllerViewDataEvent¶
New in version 12.3
The PSR-14 event
\TYPO3\CMS\Redirects\Event\ModifyRedirectManagementControllerViewDataEvent
allows extensions to modify or enrich view data for
EXT:redirects/Classes/Controller/ManagementController.php (GitHub). This makes it
possible to display more or other information along the way.
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.
New in version 13.0
The methods getIntegrityStatusCodes()
and
setIntegrityStatusCodes()
have been added to the event class.
Example¶
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Redirects\EventListener;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Redirects\Event\ModifyRedirectManagementControllerViewDataEvent;
#[AsEventListener(
identifier: 'my-extension/modify-redirect-management-controller-view-data',
)]
final readonly 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'] !== '*');
// Ipdate changed hosts list
$event->setHosts($hosts);
}
}
New in version 13.0
The PHP attribute \TYPO3\CMS\Core\Attribute\AsEventListener
has been
introduced to tag a PHP class as an event listener. Alternatively, or if you
need to be compatible with older TYPO3 versions, you can also register an
event listener via the Configuration/Services.yaml
file. Switch to
an older version of this page for an example or have a look at the section
Implementing an event listener in your extension.
API¶
- class \TYPO3\CMS\Redirects\Event\ ModifyRedirectManagementControllerViewDataEvent¶
-
This event is fired in the TYPO3CMSRedirectsControllerManagementController handleRequest() method.
It can be used to further enrich view data for the management view.
- getDemand ( ) ¶
-
Return the demand object used to retrieve the redirects.
- returntype
-
TYPO3\CMS\Redirects\Repository\Demand
- setDemand ( TYPO3\\CMS\\Redirects\\Repository\\Demand $demand) ¶
-
Can be used to set the demand object.
- param TYPO3\\CMS\\Redirects\\Repository\\Demand $demand
-
the demand
- getRedirects ( ) ¶
-
Return the retrieved redirects.
- returntype
-
array
- setRedirects ( array $redirects) ¶
-
Can be used to set the redirects, for example, after enriching redirect fields.
- param array $redirects
-
the redirects
- getRequest ( ) ¶
-
Return the current PSR-7 request.
- returntype
-
Psr\Http\Message\ServerRequestInterface
- getHosts ( ) ¶
-
Returns the hosts to be used for the host filter select box.
- returntype
-
array
- setHosts ( array $hosts) ¶
-
Can be used to update which hosts are available in the filter select box.
- param array $hosts
-
the hosts
- getStatusCodes ( ) ¶
-
Returns the status codes for the filter select box.
- returntype
-
array
- setStatusCodes ( array $statusCodes) ¶
-
Can be used to update which status codes are available in the filter select box.
- param array $statusCodes
-
the statusCodes
- getCreationTypes ( ) ¶
-
Returns creation types for the filter select box.
- returntype
-
array
- setCreationTypes ( array $creationTypes) ¶
-
Can be used to update which creation types are available in the filter select box.
- param array $creationTypes
-
the creationTypes
- getShowHitCounter ( ) ¶
-
Returns, if hit counter should be displayed.
- returntype
-
bool
- setShowHitCounter ( bool $showHitCounter) ¶
-
Can be used to manage, if the hit counter should be displayed.
- param bool $showHitCounter
-
the showHitCounter
- getView ( ) ¶
-
Returns the current view object, without controller data assigned yet.
- returntype
-
TYPO3\CMS\Core\View\ViewInterface
- setView ( TYPO3\\CMS\\Core\\View\\ViewInterface $view) ¶
-
Can be used to assign additional data to the view.
- param TYPO3\\CMS\\Core\\View\\ViewInterface $view
-
the view
- getIntegrityStatusCodes ( ) ¶
-
Returns all integrity status codes.
- returntype
-
array
- setIntegrityStatusCodes ( array $integrityStatusCodes) ¶
-
Allows to set integrity status codes. It can be used to filter for integrity status codes.
- param array $integrityStatusCodes
-
the integrityStatusCodes