‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Configuration\SiteConfiguration Class Reference
Inheritance diagram for TYPO3\CMS\Core\Configuration\SiteConfiguration:
TYPO3\CMS\Core\SingletonInterface

Public Member Functions

 __construct (protected string $configPath, protected EventDispatcherInterface $eventDispatcher, protected PhpFrontend $cache)
 
Site[] getAllExistingSites (bool $useCache=true)
 
 createNewBasicSite (string $identifier, int $rootPageId, string $base)
 
Site[] resolveAllExistingSites (bool $useCache=true)
 
Site[] resolveAllExistingSitesRaw ()
 
 getAllSiteConfigurationPaths ()
 
 load (string $siteIdentifier)
 
 writeSettings (string $siteIdentifier, array $settings)
 
 write (string $siteIdentifier, array $configuration, bool $protectPlaceholders=false)
 
 rename (string $currentIdentifier, string $newIdentifier)
 
 delete (string $siteIdentifier)
 
 warmupCaches (CacheWarmupEvent $event)
 

Protected Member Functions

 getAllSiteConfigurationFromFiles (bool $useCache=true)
 
 getSiteSettings (string $siteIdentifier, array $siteConfiguration)
 
 getContentSecurityPolicies (string $siteIdentifier)
 
array< string, protectPlaceholders(array $existingConfiguration, array $modifiedConfiguration):array { try { return GeneralUtility::makeInstance(YamlPlaceholderGuard::class, $existingConfiguration) -> process ($modifiedConfiguration)
 
catch(YamlPlaceholderException $exception) sortConfiguration (array $newConfiguration)
 

Static Protected Member Functions

static findModified (array $currentConfiguration, array $newConfiguration)
 
static findRemoved (array $currentConfiguration, array $newConfiguration)
 

Protected Attributes

string $configFileName = 'config.yaml'
 
string $settingsFileName = 'settings.yaml'
 
string $contentSecurityFileName = 'csp.yaml'
 
string $cacheIdentifier = 'sites-configuration'
 
array null $firstLevelCache
 

Detailed Description

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.

Definition at line 46 of file SiteConfiguration.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Configuration\SiteConfiguration::__construct ( protected string  $configPath,
protected EventDispatcherInterface  $eventDispatcher,
protected PhpFrontend  $cache 
)

Definition at line 83 of file SiteConfiguration.php.

Member Function Documentation

◆ createNewBasicSite()

TYPO3\CMS\Core\Configuration\SiteConfiguration::createNewBasicSite ( string  $identifier,
int  $rootPageId,
string  $base 
)

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

Exceptions
SiteConfigurationWriteException

Definition at line 107 of file SiteConfiguration.php.

References TYPO3\CMS\Core\Configuration\SiteConfiguration\write().

◆ delete()

TYPO3\CMS\Core\Configuration\SiteConfiguration::delete ( string  $siteIdentifier)

Removes the config.yaml file of a site configuration. Also clears the cache.

Exceptions
SiteNotFoundException|SiteConfigurationWriteException

Definition at line 352 of file SiteConfiguration.php.

References TYPO3\CMS\Core\Configuration\SiteConfiguration\$configFileName, TYPO3\CMS\Webhooks\Message\$siteIdentifier, and TYPO3\CMS\Core\Configuration\SiteConfiguration\getAllExistingSites().

◆ findModified()

static TYPO3\CMS\Core\Configuration\SiteConfiguration::findModified ( array  $currentConfiguration,
array  $newConfiguration 
)
staticprotected

Definition at line 399 of file SiteConfiguration.php.

◆ findRemoved()

static TYPO3\CMS\Core\Configuration\SiteConfiguration::findRemoved ( array  $currentConfiguration,
array  $newConfiguration 
)
staticprotected

Definition at line 419 of file SiteConfiguration.php.

◆ getAllExistingSites()

Site [] TYPO3\CMS\Core\Configuration\SiteConfiguration::getAllExistingSites ( bool  $useCache = true)

◆ getAllSiteConfigurationFromFiles()

TYPO3\CMS\Core\Configuration\SiteConfiguration::getAllSiteConfigurationFromFiles ( bool  $useCache = true)
protected

◆ getAllSiteConfigurationPaths()

TYPO3\CMS\Core\Configuration\SiteConfiguration::getAllSiteConfigurationPaths ( )

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

Definition at line 182 of file SiteConfiguration.php.

References $finder.

◆ getContentSecurityPolicies()

◆ getSiteSettings()

TYPO3\CMS\Core\Configuration\SiteConfiguration::getSiteSettings ( string  $siteIdentifier,
array  $siteConfiguration 
)
protected

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

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.

Definition at line 257 of file SiteConfiguration.php.

References TYPO3\CMS\Core\Configuration\SiteConfiguration\$settingsFileName, and TYPO3\CMS\Webhooks\Message\$siteIdentifier.

Referenced by TYPO3\CMS\Core\Configuration\SiteConfiguration\resolveAllExistingSites().

◆ load()

TYPO3\CMS\Core\Configuration\SiteConfiguration::load ( string  $siteIdentifier)

Load plain configuration without additional settings.

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
string$siteIdentifier

Definition at line 241 of file SiteConfiguration.php.

References TYPO3\CMS\Core\Configuration\SiteConfiguration\$configFileName, TYPO3\CMS\Webhooks\Message\$siteIdentifier, and TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader\PROCESS_IMPORTS.

Referenced by TYPO3\CMS\Install\Updates\MigrateSiteSettingsConfigUpdate\getSitePathsToMigrate().

◆ process()

array<string, protectPlaceholders(array $existingConfiguration, array $modifiedConfiguration): array { try { return GeneralUtility::makeInstance(YamlPlaceholderGuard::class, $existingConfiguration) -> TYPO3\CMS\Core\Configuration\SiteConfiguration::process (   $modifiedConfiguration)
protected

Detects placeholders that have been introduced and handles* them. (*) currently throws an exception, but could be purged or escaped as well

Parameters
array<string,mixed>‪$existingConfiguration
array<string,mixed>‪$modifiedConfiguration
Returns
‪array<string, mixed> sanitized configuration (currently not used, exception thrown before)
Exceptions
SiteConfigurationWriteException

◆ rename()

TYPO3\CMS\Core\Configuration\SiteConfiguration::rename ( string  $currentIdentifier,
string  $newIdentifier 
)

Renames a site identifier (and moves the folder)

Exceptions
SiteConfigurationWriteException

Definition at line 337 of file SiteConfiguration.php.

◆ resolveAllExistingSites()

Site [] TYPO3\CMS\Core\Configuration\SiteConfiguration::resolveAllExistingSites ( bool  $useCache = true)

◆ resolveAllExistingSitesRaw()

Site [] TYPO3\CMS\Core\Configuration\SiteConfiguration::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.

Returns
Site[]

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

Definition at line 160 of file SiteConfiguration.php.

References TYPO3\CMS\Webhooks\Message\$identifier, and TYPO3\CMS\Core\Configuration\SiteConfiguration\getAllSiteConfigurationFromFiles().

◆ sortConfiguration()

catch (YamlPlaceholderException $exception) TYPO3\CMS\Core\Configuration\SiteConfiguration::sortConfiguration ( array  $newConfiguration)
protected

◆ warmupCaches()

TYPO3\CMS\Core\Configuration\SiteConfiguration::warmupCaches ( CacheWarmupEvent  $event)

◆ write()

TYPO3\CMS\Core\Configuration\SiteConfiguration::write ( string  $siteIdentifier,
array  $configuration,
bool  $protectPlaceholders = false 
)

Add or update a site configuration

Parameters
bool$protectPlaceholders‪whether to disallow introducing new placeholders
Todo:
‪enforce $protectPlaceholders with TYPO3 v13.0
Exceptions
SiteConfigurationWriteException

Definition at line 295 of file SiteConfiguration.php.

References TYPO3\CMS\Core\Configuration\SiteConfiguration\$configFileName, TYPO3\CMS\Webhooks\Message\$siteIdentifier, TYPO3\CMS\Core\Utility\GeneralUtility\mkdir_deep(), TYPO3\CMS\Core\Configuration\SiteConfiguration\sortConfiguration(), and TYPO3\CMS\Core\Utility\GeneralUtility\writeFile().

Referenced by TYPO3\CMS\Core\Configuration\SiteConfiguration\createNewBasicSite().

◆ writeSettings()

TYPO3\CMS\Core\Configuration\SiteConfiguration::writeSettings ( string  $siteIdentifier,
array  $settings 
)

Member Data Documentation

◆ $cacheIdentifier

string TYPO3\CMS\Core\Configuration\SiteConfiguration::$cacheIdentifier = 'sites-configuration'
protected

Identifier to store all configuration data in cache_core cache.

Definition at line 74 of file SiteConfiguration.php.

◆ $configFileName

string TYPO3\CMS\Core\Configuration\SiteConfiguration::$configFileName = 'config.yaml'
protected

◆ $contentSecurityFileName

string TYPO3\CMS\Core\Configuration\SiteConfiguration::$contentSecurityFileName = 'csp.yaml'
protected

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

Definition at line 67 of file SiteConfiguration.php.

Referenced by TYPO3\CMS\Core\Configuration\SiteConfiguration\getContentSecurityPolicies().

◆ $firstLevelCache

array null TYPO3\CMS\Core\Configuration\SiteConfiguration::$firstLevelCache
protected

Cache stores all configuration as Site objects, as long as they haven't been changed. This drastically improves performance as SiteFinder utilizes SiteConfiguration heavily

Definition at line 81 of file SiteConfiguration.php.

Referenced by TYPO3\CMS\Core\Configuration\SiteConfiguration\getAllExistingSites().

◆ $settingsFileName

string TYPO3\CMS\Core\Configuration\SiteConfiguration::$settingsFileName = 'settings.yaml'
protected