BeforeLoadedUserTsConfigEvent

New in version 13.0

The PSR-14 event \TYPO3\CMS\Core\TypoScript\IncludeTree\Event\BeforeLoadedUserTsConfigEvent can be used to add global static user TSconfig before anything else is loaded. This is especially useful, if user TSconfig is generated automatically as a string from a PHP function.

It is important to understand that this configuration is considered static and thus should not depend on runtime / request.

Example

EXT:my_extension/Classes/TypoScript/EventListener/MyEventListener.php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\TypoScript\EventListener;

use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\TypoScript\IncludeTree\Event\BeforeLoadedUserTsConfigEvent;

#[AsEventListener(
    identifier: 'my-extension/global-usertsconfig',
)]
final readonly class MyEventListener
{
    public function __invoke(BeforeLoadedUserTsConfigEvent $event): void
    {
        $event->addTsConfig('global = a global setting');
    }
}
Copied!

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.

API

class \TYPO3\CMS\Core\TypoScript\IncludeTree\Event\ BeforeLoadedUserTsConfigEvent

Extensions can add global user TSconfig right before they are loaded from other sources like the global user.tsconfig file.

Note: The added config should not depend on runtime / request. This is considered static config and thus should be identical on every request.

getTsConfig ( )
returntype

array

addTsConfig ( string $tsConfig)
param string $tsConfig

the tsConfig

setTsConfig ( array $tsConfig)
param array $tsConfig

the tsConfig