SiteConfiguration implements SingletonInterface

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.

Internal

Table of Contents

Interfaces

SingletonInterface
"empty" interface for singletons (marker interface pattern)

Properties

$cache  : PhpFrontend
$cacheIdentifier  : string
Identifier to store all configuration data in the core cache.
$configFileName  : string
Config yaml file name.
$configPath  : string
$contentSecurityFileName  : string
YAML file name with all settings related to Content-Security-Policies.
$eventDispatcher  : EventDispatcherInterface
$firstLevelCache  : array<string|int, mixed>|null
Cache stores all configuration as Site objects, as long as they haven't been changed.
$settingsFileName  : string
YAML file name with all settings.

Methods

__construct()  : mixed
createNewBasicSite()  : void
Creates a site configuration with one language "English" which is the de-facto default language for TYPO3 in general.
delete()  : void
Removes the config.yaml file of a site configuration.
getAllExistingSites()  : array<string|int, Site>
Return all site objects which have been found in the filesystem.
getAllSiteConfigurationPaths()  : array<string|int, mixed>
Returns an array of paths in which a site configuration is found.
load()  : array<string|int, mixed>
Load plain configuration without additional settings.
rename()  : void
Renames a site identifier (and moves the folder)
resolveAllExistingSites()  : array<string|int, Site>
Resolve all site objects which have been found in the filesystem.
resolveAllExistingSitesRaw()  : array<string|int, 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.
warmupCaches()  : void
write()  : void
Add or update a site configuration
writeSettings()  : void
findModified()  : array<string|int, mixed>
findRemoved()  : array<string|int, mixed>
getAllSiteConfigurationFromFiles()  : array<string|int, mixed>
Read the site configuration from config files.
getContentSecurityPolicies()  : array<string|int, mixed>
getSiteSettings()  : SiteSettings
Fetch the settings for a specific site and return the parsed Site Settings object.
protectPlaceholders()  : array<string, mixed>
Detects placeholders that have been introduced and handles* them.
sortConfiguration()  : array<string|int, mixed>

Properties

$cacheIdentifier

Identifier to store all configuration data in the core cache.

protected string $cacheIdentifier = 'sites-configuration'
Internal

$configFileName

Config yaml file name.

protected string $configFileName = 'config.yaml'
Internal

$contentSecurityFileName

YAML file name with all settings related to Content-Security-Policies.

protected string $contentSecurityFileName = 'csp.yaml'
Internal

$eventDispatcher

protected EventDispatcherInterface $eventDispatcher

$firstLevelCache

Cache stores all configuration as Site objects, as long as they haven't been changed.

protected array<string|int, mixed>|null $firstLevelCache

This drastically improves performance as SiteFinder utilizes SiteConfiguration heavily

$settingsFileName

YAML file name with all settings.

protected string $settingsFileName = 'settings.yaml'
Internal

Methods

__construct()

public __construct(string $configPath, EventDispatcherInterface $eventDispatcher[, PhpFrontend|null $coreCache = null ]) : mixed
Parameters
$configPath : string
$eventDispatcher : EventDispatcherInterface
$coreCache : PhpFrontend|null = null

createNewBasicSite()

Creates a site configuration with one language "English" which is the de-facto default language for TYPO3 in general.

public createNewBasicSite(string $identifier, int $rootPageId, string $base) : void
Parameters
$identifier : string
$rootPageId : int
$base : string
Tags
throws
SiteConfigurationWriteException

getAllExistingSites()

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

public getAllExistingSites([bool $useCache = true ]) : array<string|int, Site>
Parameters
$useCache : bool = true
Return values
array<string|int, Site>

getAllSiteConfigurationPaths()

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

public getAllSiteConfigurationPaths() : array<string|int, mixed>
Internal
Return values
array<string|int, mixed>

load()

Load plain configuration without additional settings.

public load(string $siteIdentifier) : array<string|int, mixed>

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<string|int, mixed>

rename()

Renames a site identifier (and moves the folder)

public rename(string $currentIdentifier, string $newIdentifier) : void
Parameters
$currentIdentifier : string
$newIdentifier : string
Tags
throws
SiteConfigurationWriteException

resolveAllExistingSites()

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

public resolveAllExistingSites([bool $useCache = true ]) : array<string|int, Site>
Parameters
$useCache : bool = true
Return values
array<string|int, 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() : array<string|int, Site>
Internal

Not part of public API. Used as intermediate solution until settings are handled by a dedicated GUI.

Return values
array<string|int, Site>

write()

Add or update a site configuration

public write(string $siteIdentifier, array<string|int, mixed> $configuration[, bool $protectPlaceholders = false ]) : void
Parameters
$siteIdentifier : string
$configuration : array<string|int, mixed>
$protectPlaceholders : bool = false

whether to disallow introducing new placeholders

Tags
todo

enforce $protectPlaceholders with TYPO3 v13.0

throws
SiteConfigurationWriteException

writeSettings()

public writeSettings(string $siteIdentifier, array<string|int, mixed> $settings) : void
Parameters
$siteIdentifier : string
$settings : array<string|int, mixed>

findModified()

protected static findModified(array<string|int, mixed> $currentConfiguration, array<string|int, mixed> $newConfiguration) : array<string|int, mixed>
Parameters
$currentConfiguration : array<string|int, mixed>
$newConfiguration : array<string|int, mixed>
Return values
array<string|int, mixed>

findRemoved()

protected static findRemoved(array<string|int, mixed> $currentConfiguration, array<string|int, mixed> $newConfiguration) : array<string|int, mixed>
Parameters
$currentConfiguration : array<string|int, mixed>
$newConfiguration : array<string|int, mixed>
Return values
array<string|int, mixed>

getAllSiteConfigurationFromFiles()

Read the site configuration from config files.

protected getAllSiteConfigurationFromFiles([bool $useCache = true ]) : array<string|int, mixed>
Parameters
$useCache : bool = true
Tags
throws
InvalidDataException
Return values
array<string|int, mixed>

getContentSecurityPolicies()

protected getContentSecurityPolicies(string $siteIdentifier) : array<string|int, mixed>
Parameters
$siteIdentifier : string
Return values
array<string|int, mixed>

getSiteSettings()

Fetch the settings for a specific site and return the parsed Site Settings object.

protected getSiteSettings(string $siteIdentifier, array<string|int, mixed> $siteConfiguration) : SiteSettings
Parameters
$siteIdentifier : string
$siteConfiguration : array<string|int, mixed>
Tags
todo

This method resolves placeholders during the loading, which is okay as this is only used in context where the replacement is needed. However, this may change in the future, for example if loading is needed for implementing a GUI for the settings - which should either get a dedicated method or a flag to control if placeholder should be resolved during yaml file loading or not. The SiteConfiguration save action currently avoid calling this method.

Return values
SiteSettings

protectPlaceholders()

Detects placeholders that have been introduced and handles* them.

protected protectPlaceholders(array<string, mixed> $existingConfiguration, array<string, mixed> $modifiedConfiguration) : array<string, mixed>

(*) currently throws an exception, but could be purged or escaped as well

Parameters
$existingConfiguration : array<string, mixed>
$modifiedConfiguration : array<string, mixed>
Tags
throws
SiteConfigurationWriteException
Return values
array<string, mixed>

sanitized configuration (currently not used, exception thrown before)

sortConfiguration()

protected sortConfiguration(array<string|int, mixed> $newConfiguration) : array<string|int, mixed>
Parameters
$newConfiguration : array<string|int, mixed>
Return values
array<string|int, mixed>

        
On this page

Search results