BeforeTcaOverridesEvent¶
New in version 13.0.
A PSR-14 event \TYPO3\CMS\Core\Configuration\Event\BeforeTcaOverridesEvent
enables developers to listen to the state between loaded base TCA and merging of
TCA overrides.
It can be used to dynamically generate TCA and add it as additional base TCA. This is especially useful for "TCA generator" extensions, which add TCA based on another resource, while still enabling users to override TCA via the known TCA overrides API.
Note
$GLOBALS['TCA']
is not set at this point. Event listeners can only
work on the TCA coming from $event->getTca()
and
must not access $GLOBALS['TCA']
.
TCA is always "runtime-cached". This means that dynamic additions must never depend on runtime state, for example, the current PSR-7 request or similar, because such information might not even exist when the first call is done, for example, from CLI.
Example¶
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Configuration\EventListener;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Configuration\Event\BeforeTcaOverridesEvent;
#[AsEventListener(
identifier: 'my-extension/before-tca-overrides'
)]
final class MyEventListener
{
public function __invoke(BeforeTcaOverridesEvent $event): void
{
$tca = $event->getTca();
$tca['tt_content']['columns']['header']['config']['max'] = 100;
$event->setTca($tca);
}
}
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, you can also
register an event listener via the Configuration/Services.yaml
file. Have
a look into the section Implementing an event listener in your extension.