class ConfigurationManager (View source)

A general purpose configuration manager

Constants

CONFIGURATION_TYPE_CACHES

Contains a list of caches which are registered automatically. Caches defined in this configuration file are registered in an early stage of the boot process and profit from mechanisms such as automatic flushing by the File Monitor. See the chapter about the Cache Framework for details.

CONFIGURATION_TYPE_OBJECTS

Contains object configuration, i.e. options which configure objects and the combination of those on a lower level. See the Object Framework chapter for more information.

CONFIGURATION_TYPE_ROUTES

Contains routes configuration. This routing information is parsed and used by the MVC Web Routing mechanism.

Refer to the Routing chapter for more information.

CONFIGURATION_TYPE_POLICY

Contains the configuration of the security policies of the system. See the Security chapter for details.

CONFIGURATION_TYPE_SETTINGS

Contains user-level settings, i.e. configuration options the users or administrators are meant to change.

Settings are the highest level of system configuration.

CONFIGURATION_PROCESSING_TYPE_DEFAULT

This is the default processing, which merges configurations similar to how CONFIGURATION_PROCESSING_TYPE_SETTINGS are merged (except that for settings an empty array is initialized for each package)

CONFIGURATION_PROCESSING_TYPE_OBJECTS

Appends all configurations, prefixed by the PackageKey of the configuration source

CONFIGURATION_PROCESSING_TYPE_POLICY

Loads and merges configurations from Packages (global Policy-configurations are not allowed)

CONFIGURATION_PROCESSING_TYPE_ROUTES

Loads and appends global configurations and resolves SubRoutes, creating a combined flat array of all Routes

CONFIGURATION_PROCESSING_TYPE_SETTINGS

Similar to CONFIGURATION_PROCESSING_TYPE_DEFAULT, but for every active package an empty array is initialized.

Besides this sets "Neos.Flow.core.context" to the current context

CONFIGURATION_PROCESSING_TYPE_APPEND

Appends all configurations to one flat array

Properties

protected array $configurationTypes

Defines which Configuration Type is processed by which logic

protected ApplicationContext $context

The application context of the configuration to manage

protected array $orderedListOfContextNames

An array of context name strings, from the most generic one to the most special one.

protected YamlSource $configurationSource
protected array $configurations

Storage of the raw special configurations

protected FlowPackageInterface[] $packages

Active packages to load the configuration for

protected bool $cacheNeedsUpdate
protected string $temporaryDirectoryPath

An absolute file path to store configuration caches in. If null no cache will be active.

protected array $unprocessedConfiguration

Methods

__construct(ApplicationContext $context)

Constructs the configuration manager

void
injectConfigurationSource(YamlSource $configurationSource)

Injects the configuration source

setTemporaryDirectoryPath(string $temporaryDirectoryPath)

Set an absolute file path to store configuration caches in. If null no cache will be active.

void
setPackages(array $packages)

Sets the active packages to load the configuration for

array
getAvailableConfigurationTypes()

Get the available configuration-types

string
resolveConfigurationProcessingType(string $configurationType)

Resolve the processing type for the configuration type.

bool
isSplitSourceAllowedForConfigurationType(string $configurationType)

Check the allowSplitSource setting for the configuration type.

void
registerConfigurationType(string $configurationType, string $configurationProcessingType = self::CONFIGURATION_PROCESSING_TYPE_DEFAULT, bool $allowSplitSource = true)

Registers a new configuration type with the given configuration processing type.

void
emitConfigurationManagerReady(ConfigurationManager $configurationManager)

Emits a signal after The ConfigurationManager has been loaded

array|null
getConfiguration(string $configurationType, string $configurationPath = null)

Returns the specified raw configuration.

void
shutdown()

Shuts down the configuration manager.

void
warmup()

Warms up the complete configuration cache, i.e. fetching every configured configuration type in order to be able to store it into the cache, if configured to do so.

void
loadConfiguration(string $configurationType, array $packages)

Loads special configuration defined in the specified packages and merges them with those potentially existing in the global configuration folders. The result is stored in the configuration manager's configuration registry and can be retrieved with the getConfiguration() method.

bool
loadConfigurationCache()

If a cache file with previously saved configuration exists, it is loaded.

void
flushConfigurationCache()

If a cache file with previously saved configuration exists, it is removed.

void
saveConfigurationCache()

Saves the current configuration into a cache file and creates a cache inclusion script in the context's Configuration directory.

void
refreshConfiguration()

No description

mixed
replaceVariablesInPhpString(string $phpString)

Replaces variables (in the format %CONSTANT% or %env:ENVIRONMENT_VARIABLE%) in the given php exported configuration string.

array
mergePolicyConfiguration(array $firstConfigurationArray, array $secondConfigurationArray)

Merges two policy configuration arrays.

string
constructConfigurationCachePath()

Constructs a path to the configuration cache PHP file.

Details

__construct(ApplicationContext $context)

Constructs the configuration manager

Parameters

ApplicationContext $context

The application context to fetch configuration for

void injectConfigurationSource(YamlSource $configurationSource)

Injects the configuration source

Parameters

YamlSource $configurationSource

Return Value

void

setTemporaryDirectoryPath(string $temporaryDirectoryPath)

Set an absolute file path to store configuration caches in. If null no cache will be active.

Parameters

string $temporaryDirectoryPath

void setPackages(array $packages)

Sets the active packages to load the configuration for

Parameters

array $packages

Return Value

void

array getAvailableConfigurationTypes()

Get the available configuration-types

Return Value

array

array of configuration-type identifier strings

string resolveConfigurationProcessingType(string $configurationType)

Resolve the processing type for the configuration type.

This returns the CONFIGURATION_PROCESSINGTYPE* to use for the given $configurationType.

Parameters

string $configurationType

Return Value

string

Exceptions

InvalidConfigurationTypeException

bool isSplitSourceAllowedForConfigurationType(string $configurationType)

Check the allowSplitSource setting for the configuration type.

Parameters

string $configurationType

Return Value

bool

Exceptions

InvalidConfigurationTypeException

void registerConfigurationType(string $configurationType, string $configurationProcessingType = self::CONFIGURATION_PROCESSING_TYPE_DEFAULT, bool $allowSplitSource = true)

Registers a new configuration type with the given configuration processing type.

The processing type must be supported by the ConfigurationManager, see CONFIGURATION_PROCESSINGTYPE* for what is available.

Parameters

string $configurationType

The type to register, may be anything

string $configurationProcessingType

One of CONFIGURATION_PROCESSINGTYPE*, defaults to CONFIGURATION_PROCESSING_TYPE_DEFAULT

bool $allowSplitSource

If true, the type will be used as a "prefix" when looking for split configuration. Only supported for DEFAULT and SETTINGS processing types!

Return Value

void

Exceptions

InvalidArgumentException

protected void emitConfigurationManagerReady(ConfigurationManager $configurationManager)

Emits a signal after The ConfigurationManager has been loaded

Parameters

ConfigurationManager $configurationManager

Return Value

void

array|null getConfiguration(string $configurationType, string $configurationPath = null)

Returns the specified raw configuration.

The actual configuration will be merged from different sources in a defined order.

Note that this is a low level method and mostly makes sense to be used by Flow internally. If possible just use settings and have them injected.

Parameters

string $configurationType

The kind of configuration to fetch - must be one of the CONFIGURATIONTYPE* constants

string $configurationPath

The path inside the configuration to fetch

Return Value

array|null

The configuration or NULL if the configuration doesn't exist

Exceptions

InvalidConfigurationTypeException

void shutdown()

Shuts down the configuration manager.

This method writes the current configuration into a cache file if Flow was configured to do so.

Return Value

void

void warmup()

Warms up the complete configuration cache, i.e. fetching every configured configuration type in order to be able to store it into the cache, if configured to do so.

Return Value

void

See also

ConfigurationManager::shutdown

protected void loadConfiguration(string $configurationType, array $packages)

Loads special configuration defined in the specified packages and merges them with those potentially existing in the global configuration folders. The result is stored in the configuration manager's configuration registry and can be retrieved with the getConfiguration() method.

Parameters

string $configurationType

The kind of configuration to load - must be one of the CONFIGURATIONTYPE* constants

array $packages

An array of Package objects (indexed by package key) to consider

Return Value

void

Exceptions

InvalidConfigurationTypeException
InvalidConfigurationException

bool loadConfigurationCache()

If a cache file with previously saved configuration exists, it is loaded.

Return Value

bool

If cached configuration was loaded or not

void flushConfigurationCache()

If a cache file with previously saved configuration exists, it is removed.

Internal: After this the configuration manager is left without any configuration, use refreshConfiguration if you want to reread the configuration.

Return Value

void

Exceptions

Exception

See also

refreshConfiguration

protected void saveConfigurationCache()

Saves the current configuration into a cache file and creates a cache inclusion script in the context's Configuration directory.

Return Value

void

Exceptions

Exception

void refreshConfiguration()

No description

Return Value

void

protected mixed replaceVariablesInPhpString(string $phpString)

Replaces variables (in the format %CONSTANT% or %env:ENVIRONMENT_VARIABLE%) in the given php exported configuration string.

This is applied before caching to alllow runtime evaluation of constants and environment variables.

Parameters

string $phpString

Return Value

mixed

protected array mergePolicyConfiguration(array $firstConfigurationArray, array $secondConfigurationArray)

Merges two policy configuration arrays.

Parameters

array $firstConfigurationArray
array $secondConfigurationArray

Return Value

array

protected string constructConfigurationCachePath()

Constructs a path to the configuration cache PHP file.

Derived from the temporary path and application context.

Return Value

string