Feature: #97454 - PSR-14 events for modifying link browser behavior¶
See forge#97454
Description¶
Two new PSR-14 events \TYPO3\CMS\Backend\Controller\Event\ModifyLinkHandlersEvent
and
\TYPO3\CMS\Backend\Controller\Event\ModifyAllowedItemsEvent
have been introduced which
serve as a direct replacement for the now removed
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['LinkBrowser']['hooks']
hooks.
The ModifyLinkHandlersEvent
is triggered before link handlers are
executed, allowing listeners to modify the set of handlers that will be used.
It is the direct replacement for the method modifyLinkHandlers()
in the
LinkBrowser hook.
The ModifyAllowedItemsEvent
can be used to dynamically modify the
allowed link types. It is the direct replacement for the method modifyAllowedItems()
in the LinkBrowser hook.
Example¶
Registration of the event in your extension's Services.yaml
:
MyVendor\MyPackage\MyEventListener:
tags:
- name: event.listener
identifier: 'my-package/recordlist/link-handlers'
The corresponding event listener class:
use TYPO3\CMS\Backend\Controller\Event\ModifyLinkHandlersEvent;
final class MyEventListener
{
public function __invoke(ModifyLinkHandlersEvent $event): void
{
$handler = $event->getLinkHandler('url.');
$handler['label'] = 'My custom label';
$event->setLinkHandler('url.', $handler);
}
}
Impact¶
It's now possible to modify link handlers behavior using the new PSR-14
ModifyLinkHandlersEvent
and ModifyAllowedItemsEvent
.