| Current Path : /var/www/surf/TYPO3/vendor/b13/container/Classes/Listener/ |
| Current File : /var/www/surf/TYPO3/vendor/b13/container/Classes/Listener/PageTsConfig.php |
<?php
declare(strict_types=1);
namespace B13\Container\Listener;
/*
* This file is part of TYPO3 CMS-based extension "container" by b13.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*/
use B13\Container\Tca\Registry;
use TYPO3\CMS\Core\Configuration\Event\ModifyLoadedPageTsConfigEvent;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class PageTsConfig
{
/**
* @var Registry
*/
protected $tcaRegistry;
public function __construct(Registry $tcaRegistry)
{
$this->tcaRegistry = $tcaRegistry;
}
public function __invoke(ModifyLoadedPageTsConfigEvent $event): void
{
$tsConfig = $event->getTsConfig();
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() > 11) {
$tsConfig = array_merge(['pageTsConfig-package-container' => $this->tcaRegistry->getPageTsString()], $tsConfig);
} else {
$tsConfig['default'] = trim($this->tcaRegistry->getPageTsString() . "\n" . ($tsConfig['default'] ?? ''));
}
$event->setTsConfig($tsConfig);
}
}