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¶
<?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 class MyEventListener
{
public function __invoke(BeforeLoadedPageTsConfigEvent $event): void
{
$event->addTsConfig('global = a global setting');
}
}
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()¶
- Return type
array
- addTsConfig(string $tsConfig)¶
- Parameters
$tsConfig (
string
) -- the tsConfig
- setTsConfig(array $tsConfig)¶
- Parameters
$tsConfig (
array
) -- the tsConfig