BeforeLoadedPageTsConfigEvent

New in version 13.0

The PSR-14 event \TYPO3\CMS\Core\TypoScript\IncludeTree\Event\BeforeLoadedPageTsConfigEvent can be used to add global static page TSconfig before anything else is loaded. This is especially useful, if page 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\BeforeLoadedPageTsConfigEvent;

#[AsEventListener(
    identifier: 'my-extension/global-pagetsconfig',
)]
final readonly class MyEventListener
{
    public function __invoke(BeforeLoadedPageTsConfigEvent $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\ BeforeLoadedPageTsConfigEvent

Extensions can add global page TSconfig right before they are loaded from other sources like the global page.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