Detailed Description
Implementations of Configuration give access to the application configuration.
An instance of a Configuration implementation must be created on application startup and must be registered at ObjectFactory using the ObjectFactory::registerInstance() method.
Configurations are supposed to be separated into sections, that contain keys with values. Section names and keys are treated case insensitive.
There maybe more than one application configuration. You can retrieve their names by using the Configuration::getConfigurations() method. Different configurations maybe merged by calling the Configuration::addConfiguration() method. While merging, existing values will be overwritten, while new values will be added. This allows to have very flexible application configurations for different scenarios, users and roles.
Definition at line 32 of file Configuration.php.
Public Member Functions | |
getConfigurations () | |
addConfiguration ($name, $processValues=true) | |
getSections () | |
hasSection ($section) | |
getSection ($section, $includeMeta=false) | |
hasValue ($key, $section) | |
getValue ($key, $section) | |
getBooleanValue ($key, $section) | |
getDirectoryValue ($key, $section) | |
getFileValue ($key, $section) | |
getKey ($value, $section) | |
Member Function Documentation
◆ getConfigurations()
getConfigurations | ( | ) |
Get a list of available configurations.
- Returns
- Array of configuration names.
Implemented in InifileConfiguration.
◆ addConfiguration()
addConfiguration | ( | $name, | |
$processValues = true |
|||
) |
Parses the given configuration and merges it with already added configurations.
- Parameters
-
$name The name of the configuration $processValues Boolean whether values should be processed after parsing (e.g. make arrays) (default: true)
Implemented in InifileConfiguration.
◆ getSections()
getSections | ( | ) |
◆ hasSection()
hasSection | ( | $section | ) |
Check if a section exists.
- Parameters
-
$section The section to check for.
- Returns
- Boolean
Implemented in InifileConfiguration.
◆ getSection()
getSection | ( | $section, | |
$includeMeta = false |
|||
) |
Get a section.
- Parameters
-
$section The section to return. $includeMeta Boolean whether to include section meta data keys (optional, default: false)
- Returns
- Array holding the key/value pairs belonging to the section.
- Exceptions
-
ConfigurationException if the section does not exist
Implemented in InifileConfiguration.
◆ hasValue()
hasValue | ( | $key, | |
$section | |||
) |
Check if a configuration value exists.
- Parameters
-
$key The name of the value. $section The section the value belongs to.
- Returns
- Boolean
Implemented in InifileConfiguration.
◆ getValue()
getValue | ( | $key, | |
$section | |||
) |
Get a configuration value.
- Parameters
-
$key The name of the entry. $section The section the key belongs to.
- Returns
- The configuration value.
- Exceptions
-
ConfigurationException if the value does not exist
Implemented in InifileConfiguration.
◆ getBooleanValue()
getBooleanValue | ( | $key, | |
$section | |||
) |
Get a value from the configuration as boolean if it represents a boolean.
- Parameters
-
$key The name of the entry. $section The section the key belongs to.
- Returns
- Boolean or the original value.
- Exceptions
-
ConfigurationException if the value does not exist
Implemented in InifileConfiguration.
◆ getDirectoryValue()
getDirectoryValue | ( | $key, | |
$section | |||
) |
Get a directory value from the configuration.
The value will interpreted as directory relative to WCMF_BASE and returned as absolute path.
- Parameters
-
$key The name of the entry. $section The section the key belongs to.
- Returns
- The configuration value.
- Exceptions
-
ConfigurationException if the value does not exist
Implemented in InifileConfiguration.
◆ getFileValue()
getFileValue | ( | $key, | |
$section | |||
) |
Get a file value from the configuration.
The value will interpreted as file relative to WCMF_BASE and returned as absolute path.
- Parameters
-
$key The name of the entry. $section The section the key belongs to.
- Returns
- The configuration value.
- Exceptions
-
ConfigurationException if the value does not exist
Implemented in InifileConfiguration.
◆ getKey()
getKey | ( | $value, | |
$section | |||
) |
Get a configuration key.
- Parameters
-
$value The value of the entry. $section The section the value belongs to.
- Returns
- The configuration key.
- Exceptions
-
ConfigurationException if the key does not exist
Implemented in InifileConfiguration.