Configuration Interface Reference

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.

Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 32 of file Configuration.php.

+ Inheritance diagram for Configuration:

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
$nameThe name of the configuration
$processValuesBoolean whether values should be processed after parsing (e.g. make arrays) (default: true)

Implemented in InifileConfiguration.

◆ getSections()

getSections ( )

Get all section names.

Returns
An array of section names.

Implemented in InifileConfiguration.

◆ hasSection()

hasSection (   $section)

Check if a section exists.

Parameters
$sectionThe section to check for.
Returns
Boolean

Implemented in InifileConfiguration.

◆ getSection()

getSection (   $section,
  $includeMeta = false 
)

Get a section.

Parameters
$sectionThe section to return.
$includeMetaBoolean whether to include section meta data keys (optional, default: false)
Returns
Array holding the key/value pairs belonging to the section.
Exceptions
ConfigurationExceptionif the section does not exist

Implemented in InifileConfiguration.

◆ hasValue()

hasValue (   $key,
  $section 
)

Check if a configuration value exists.

Parameters
$keyThe name of the value.
$sectionThe section the value belongs to.
Returns
Boolean

Implemented in InifileConfiguration.

◆ getValue()

getValue (   $key,
  $section 
)

Get a configuration value.

Parameters
$keyThe name of the entry.
$sectionThe section the key belongs to.
Returns
The configuration value.
Exceptions
ConfigurationExceptionif 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
$keyThe name of the entry.
$sectionThe section the key belongs to.
Returns
Boolean or the original value.
Exceptions
ConfigurationExceptionif 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
$keyThe name of the entry.
$sectionThe section the key belongs to.
Returns
The configuration value.
Exceptions
ConfigurationExceptionif 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
$keyThe name of the entry.
$sectionThe section the key belongs to.
Returns
The configuration value.
Exceptions
ConfigurationExceptionif the value does not exist

Implemented in InifileConfiguration.

◆ getKey()

getKey (   $value,
  $section 
)

Get a configuration key.

Parameters
$valueThe value of the entry.
$sectionThe section the value belongs to.
Returns
The configuration key.
Exceptions
ConfigurationExceptionif the key does not exist

Implemented in InifileConfiguration.