Feature: #105649 - New PSR-14 CustomFileSelectorsEvent
See forge#105649
Description
A new PSR-14 event
\TYPO3\
has been added. It is dispatched in
Files
during the rendering of selectors for relations to sys_.
To modify the selectors used to add files, the following methods are available:
get: Get all selectorsSelectors () set: Set all selectorsSelectors () get: Get all JavaScript modulesJavascript Modules () set: Set all JavaScript modulesJavascript Modules () get: Get the table name of the current recordTable Name () get: Get the field name of the elementField Name () get: Get the raw database rowDatabase Row () get: Get the TCA configuration of the current fieldField Config () get: Get the allowed and disallowed file extensionsFile Extension Filter () get: Get the DOM object ID used in the formForm Field Identifier ()
Example
The corresponding event listener class:
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\EventListener;
use TYPO3\CMS\Backend\Form\Event\CustomFileSelectorsEvent;
use TYPO3\CMS\Core\Attribute\AsEventListener;
#[AsEventListener(identifier: 'my-extension/custom-file-selector')]
final class CustomFileSelectorEventListener
{
public function __construct(
private CustomDamFileSelector $damFileSelector,
) {}
public function __invoke(CustomFileSelectorsEvent $event): void
{
$result = $this->damFileSelector->renderFileSelector(
$event->getFormFieldIdentifier(),
);
$event->setSelectors(array_merge(
$event->getSelectors(),
$result['control'],
));
$event->setJavascriptModules(array_merge(
$event->getJavascriptModules(),
$result['javaScriptModule'],
));
}
}
Copied!
Impact
It is now possible to modify file selectors using the new PSR-14 event
Custom. This is
especially useful for integrating a DAM system.