SiteConfigurationLoadedEvent 

The PSR-14 event \TYPO3\CMS\Core\Configuration\Event\SiteConfigurationLoadedEvent allows the modification of the site configuration array before loading the configuration.

Example 

The example adds a route enhancer configuration provided by an extension with an event listener automatically. This way, there is no need to add an import manually to the site configuration.

EXT:my_extension/Classes/Configuration/EventListener/ImportRoutesIntoSiteConfiguration.php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Configuration\EventListener;

use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Configuration\Event\SiteConfigurationLoadedEvent;
use TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader;
use TYPO3\CMS\Core\Utility\ArrayUtility;

#[AsEventListener(
  identifier: 'my-extension/import-routes-into-site-configuration',
)]
final readonly class ImportRoutesIntoSiteConfiguration
{
  private const ROUTES = 'EXT:my_extension/Configuration/Routes/Routes.yaml';

  public function __construct(
    private YamlFileLoader $yamlFileLoader,
  ) {}

  public function __invoke(SiteConfigurationLoadedEvent $event): void
  {
    $routeConfiguration = $this->yamlFileLoader->load(self::ROUTES);
    $siteConfiguration = $event->getConfiguration();

    // Using this method instead of array_merge_recursive will
    // prevent duplicate keys, and also allow to use the special
    // "_UNSET" handling properly.
    ArrayUtility::mergeRecursiveWithOverrule(
      $siteConfiguration,
      $routeConfiguration,
    );

    $event->setConfiguration($siteConfiguration);
  }
}
Copied!

For more sophisticated examples, see also Automatically register route enhancer definitions stored in TYPO3 extensions.

API 

class SiteConfigurationLoadedEvent
Fully qualified name
\TYPO3\CMS\Core\Configuration\Event\SiteConfigurationLoadedEvent

Event after a site configuration has been read from a yaml file before it is cached - allows dynamic modification of the site's configuration.

getSiteIdentifier()
Returns
string
getConfiguration()
Returns
array
setConfiguration(array $configuration)
param $configuration

overwrite the configuration array of the site