SiteConfiguration

readonly class \TYPO3\CMS\Core\Configuration\SiteConfiguration

Responsibility: Handles the format of the configuration (currently yaml), and the location of the file system folder

Reads all available site configuration options, and puts them into Site objects.

Site configurations that cannot be loaded or turned into a Site object are skipped and collected as invalid sites instead, so a single broken site does not render the whole installation inaccessible. Only errors of the configuration itself are collected, as invalid sites found while loading are persisted in the core cache. Any other exception, for example of an event listener, is not caught.

Tags

phpstan-type

InvalidSite array{identifier: string, rootPageId: int|null, type: class-string<\Throwable>, code: int, message: string, field: string|null}

Attributes

#[Autoconfigure]
$public: true

Table of Contents

Properties

$cache  : PhpFrontend
$configPath  : string
$eventDispatcher  : EventDispatcherInterface
$runtimeCache  : FrontendInterface
$setRegistry  : SetRegistry
$siteSettingsFactory  : SiteSettingsFactory

Methods

__construct()  : mixed
getAllExistingSites()  : Site[]
Return all site objects which have been found in the filesystem.
getAllSiteConfigurationPaths()  : array
Returns an array of paths in which a site configuration is found.
getInvalidSiteByRootPageId()  : InvalidSite|null
getInvalidSites()  : array<string, InvalidSite>
Return all sites which could not be resolved, indexed by site identifier.
getSitesForValidation()  : array{sites: array, invalidSites: array}
Read fresh site configurations for validation without reading or writing the site caches.
load()  : array
Load plain configuration without additional settings.
resolveAllExistingSites()  : Site[]
Resolve all site objects which have been found in the filesystem.
resolveAllExistingSitesRaw()  : Site[]
Resolve all site objects which have been found in the filesystem containing settings only from the `config.yaml` file ignoring values from the `settings.yaml` and `csp.yaml` file.
siteConfigurationChanged()  : void
warmupCaches()  : void
determineInvalidSets()  : array
getAllResolvedSiteData()  : array{sites: array, invalidSites: array}
Assemble all data needed to create Site objects: the site configuration enriched with route enhancers and settings from site sets, settings objects, TypoScript and TSconfig read from the file system. This data is cached in the core cache, to avoid set resolution, settings composition and file system access per request.
getAllSiteConfigurationFromFiles()  : array
Read the site configuration from config files.
getContentSecurityPolicies()  : array
getRouteEnhancersFromSets()  : array
Get route enhancers from site sets.
getSiteTSconfig()  : SiteTSconfig|null
getSiteTypoScript()  : SiteTypoScript|null
writeCache()  : void
Persist the raw site configuration and - if available - the resolved site data in one core cache entry, to keep both in sync at all times. Invalid sites belong to the latest stage that has been written.

Properties

$configPath

protected string $configPath

Attributes

#[Autowire]
'%env(TYPO3:configPath)%/sites'

$eventDispatcher

protected EventDispatcherInterface $eventDispatcher

Methods

__construct()

public __construct(string $configPath, SiteSettingsFactory $siteSettingsFactory, SetRegistry $setRegistry, EventDispatcherInterface $eventDispatcher, PhpFrontend $cache, YamlFileLoader $yamlFileLoader, FrontendInterface $runtimeCache, LoggerInterface $logger) : mixed

Parameters

$configPath : string
$siteSettingsFactory : SiteSettingsFactory
$setRegistry : SetRegistry
$eventDispatcher : EventDispatcherInterface
$cache : PhpFrontend
$yamlFileLoader : YamlFileLoader
$runtimeCache : FrontendInterface
$logger : LoggerInterface

getAllExistingSites()

Return all site objects which have been found in the filesystem.

public getAllExistingSites([bool $useCache = true ]) : Site[]

Parameters

$useCache : bool = true

Return values

Site[]

getAllSiteConfigurationPaths()

Returns an array of paths in which a site configuration is found.

public getAllSiteConfigurationPaths() : array

Return values

array

getInvalidSiteByRootPageId()

public getInvalidSiteByRootPageId(int $rootPageId) : InvalidSite|null

Parameters

$rootPageId : int

Return values

InvalidSite|null

getInvalidSites()

Return all sites which could not be resolved, indexed by site identifier.

public getInvalidSites([bool $useCache = true ]) : array<string, InvalidSite>

Invalid sites of the most recent resolution in this request are returned. Call getAllExistingSites(false) beforehand, or pass $useCache = false, to evaluate the current state of the configuration files.

Parameters

$useCache : bool = true

Return values

array<string, InvalidSite>

getSitesForValidation()

Read fresh site configurations for validation without reading or writing the site caches.

public getSitesForValidation() : array{sites: array, invalidSites: array}

Return values

array{sites: array, invalidSites: array}

load()

Load plain configuration without additional settings.

public load(string $siteIdentifier) : array

This method should only be used in case the original configuration as it exists in the file should be loaded, for example for writing / editing configuration.

All read related actions should be performed on the site entity.

Parameters

$siteIdentifier : string

Return values

array

resolveAllExistingSites()

Resolve all site objects which have been found in the filesystem.

public resolveAllExistingSites([bool $useCache = true ]) : Site[]

Parameters

$useCache : bool = true

Return values

Site[]

resolveAllExistingSitesRaw()

Resolve all site objects which have been found in the filesystem containing settings only from the `config.yaml` file ignoring values from the `settings.yaml` and `csp.yaml` file.

public resolveAllExistingSitesRaw() : Site[]

Return values

Site[]

siteConfigurationChanged()

public siteConfigurationChanged() : void

Attributes

#[AsEventListener]
$event: SiteConfigurationChangedEvent::class

determineInvalidSets()

protected determineInvalidSets(string $siteIdentifier, array $sets) : array

Parameters

$siteIdentifier : string
$sets : array

Return values

array

getAllResolvedSiteData()

Assemble all data needed to create Site objects: the site configuration enriched with route enhancers and settings from site sets, settings objects, TypoScript and TSconfig read from the file system. This data is cached in the core cache, to avoid set resolution, settings composition and file system access per request.

protected getAllResolvedSiteData(bool $useCache) : array{sites: array, invalidSites: array}

Sites failing to load or resolve are cached as invalid sites.

Parameters

$useCache : bool

Return values

array{sites: array, invalidSites: array}

getAllSiteConfigurationFromFiles()

Read the site configuration from config files.

protected getAllSiteConfigurationFromFiles([bool $useCache = true ]) : array

Parameters

$useCache : bool = true

Tags

throws
InvalidDataException

Return values

array

getContentSecurityPolicies()

protected getContentSecurityPolicies(string $siteIdentifier) : array

Parameters

$siteIdentifier : string

Return values

array

getRouteEnhancersFromSets()

Get route enhancers from site sets.

protected getRouteEnhancersFromSets(array $dependencies) : array

Parameters

$dependencies : array

Return values

array

writeCache()

Persist the raw site configuration and - if available - the resolved site data in one core cache entry, to keep both in sync at all times. Invalid sites belong to the latest stage that has been written.

protected writeCache(array $siteConfiguration, array|null $resolvedData[, array<string, InvalidSite> $invalidSites = [] ]) : void

Parameters

$siteConfiguration : array
$resolvedData : array|null
$invalidSites : array<string, InvalidSite> = []
On this page