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

Public Member Functions

 __construct (string $configPath, ?PhpFrontend $coreCache=null)
 
Site[] getAllExistingSites (bool $useCache=true)
 
 createNewBasicSite (string $identifier, int $rootPageId, string $base)
 
Site[] resolveAllExistingSites (bool $useCache=true)
 
array load (string $siteIdentifier)
 
 write (string $siteIdentifier, array $configuration, bool $protectPlaceholders=false)
 
 rename (string $currentIdentifier, string $newIdentifier)
 
 delete (string $siteIdentifier)
 
 warmupCaches (CacheWarmupEvent $event)
 

Protected Member Functions

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

Static Protected Member Functions

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

Protected Attributes

PhpFrontend $cache
 
string $configPath
 
string $configFileName = 'config.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 42 of file SiteConfiguration.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Configuration\SiteConfiguration::__construct ( string  $configPath,
?PhpFrontend  $coreCache = null 
)
Parameters
string$configPath
PhpFrontend | null$coreCache

Definition at line 75 of file SiteConfiguration.php.

References TYPO3\CMS\Core\Configuration\SiteConfiguration\$configPath.

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.

Parameters
string$identifier
int$rootPageId
string$base
Exceptions
SiteConfigurationWriteException

Definition at line 106 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.

Parameters
string$siteIdentifier
Exceptions
SiteNotFoundException|SiteConfigurationWriteException

Definition at line 269 of file SiteConfiguration.php.

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

◆ findModified()

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

Definition at line 320 of file SiteConfiguration.php.

◆ findRemoved()

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

Definition at line 340 of file SiteConfiguration.php.

◆ getAllExistingSites()

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

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

Parameters
bool$useCache
Returns
Site[]

Definition at line 90 of file SiteConfiguration.php.

References TYPO3\CMS\Core\Configuration\SiteConfiguration\$firstLevelCache, and TYPO3\CMS\Core\Configuration\SiteConfiguration\resolveAllExistingSites().

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

◆ getAllSiteConfigurationFromFiles()

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

Read the site configuration from config files.

Parameters
bool$useCache
Returns
‪array
Exceptions
InvalidDataException

Definition at line 159 of file SiteConfiguration.php.

References $finder.

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

◆ load()

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

Load plain configuration 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
Returns
‪array

Definition at line 195 of file SiteConfiguration.php.

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

◆ 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)

Parameters
string$currentIdentifier
string$newIdentifier
Exceptions
SiteConfigurationWriteException

Definition at line 253 of file SiteConfiguration.php.

◆ resolveAllExistingSites()

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

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

Parameters
bool$useCache
Returns
Site[]

Definition at line 138 of file SiteConfiguration.php.

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

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

◆ sortConfiguration()

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

Definition at line 309 of file SiteConfiguration.php.

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

◆ 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
string$siteIdentifier
array$configuration
bool$protectPlaceholders‪whether to disallow introducing new placeholders
Exceptions
SiteConfigurationWriteException

Definition at line 210 of file SiteConfiguration.php.

References TYPO3\CMS\Core\Configuration\SiteConfiguration\$configFileName, TYPO3\CMS\Core\Utility\ArrayUtility\mergeRecursiveWithOverrule(), 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().

Member Data Documentation

◆ $cache

PhpFrontend TYPO3\CMS\Core\Configuration\SiteConfiguration::$cache
protected

Definition at line 44 of file SiteConfiguration.php.

◆ $cacheIdentifier

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

Identifier to store all configuration data in the core cache.

Definition at line 62 of file SiteConfiguration.php.

◆ $configFileName

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

◆ $configPath

string TYPO3\CMS\Core\Configuration\SiteConfiguration::$configPath
protected

◆ $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 69 of file SiteConfiguration.php.

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