Path

ez components / documentation / api reference / 1.0.1 / configuration


eZ Components 1.0.1

Configuration: ezcConfigurationManager

[ Tutorial ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcConfigurationManager

ezcConfigurationManager provides easy access to application settings. [source]
Using this class removes the need to work with specific readers and writers and also handles caching to speed up the process. This can be useful for smaller applications which don't have too many settings and does not have high memory or speed requirements.
Before the manager can be used it must be configured so it knows where to fetch the settings, this is usually at the start of the program.
1.  $man ezcConfigurationManager::getInstance();
2.  $man->init'ezcConfigurationIniReader''settings'$options );
After it is configured the rest of the code can simply access the global instance and fetch the settings using getSetting().
1.  $color ezcConfigurationManager::getInstance()->getSetting'site''Colors''Background' );

Method Summary

public bool exists( $name )
Returns true if the configuration named $name exists.
public array getArraySetting( $name, $group, $setting )
Returns the value of the setting $setting in group $group in the configuration named $name.
public bool getBoolSetting( $name, $group, $setting )
Returns the value of the setting $setting in group $group in the configuration named $name.
public static ezcConfigurationManager getInstance( )
Returns the instance of the class ezcConfigurationManager.
public int getNumberSetting( $name, $group, $setting )
Returns the value of the setting $setting in group $group in the configuration named $name.
public mixed getSetting( $name, $group, $setting )
Returns the value of the setting $setting in group $group in the configuration named $name.
public array getSettings( $name, $group, $settings )
Returns the values of the settings $settings in group $group in the configuration named $name.
public array getSettingsAsList( $name, $group, $settings )
Returns the values of the settings $settings in group $group as an array.
public string getStringSetting( $name, $group, $setting )
Returns the value of the setting $setting in group $group in the configuration named $name.
public bool hasSetting( $name, $group, $setting )
Returns whether the setting $setting exists in group $group in the configuration named $name.
public void init( $readerClass, $location, [$options = array()] )
Initializes the manager.

Methods

exists

bool exists( string $name )
Returns true if the configuration named $name exists.

Parameters

Name Type Description
$name string  

getArraySetting

array getArraySetting( string $name, string $group, string $setting )
Returns the value of the setting $setting in group $group in the configuration named $name.
Uses the fetchSetting() method to fetch the value, this method can throw exceptions. This method also validates whether the value is actually an array value.

Parameters

Name Type Description
$name string  
$group string  
$setting string  

Throws

ClassDescription
ezcConfigurationUnknownConfigException if the configuration does not exist.
ezcConfigurationUnknownGroupException if the group does not exist.
ezcConfigurationUnknownSettingException if the setting does not exist.
ezcConfigurationSettingWrongTypeException if the setting value is not an array.

See also:

fetchSetting.


getBoolSetting

bool getBoolSetting( string $name, string $group, string $setting )
Returns the value of the setting $setting in group $group in the configuration named $name.
Uses the fetchSetting() method to fetch the value, this method can throw exceptions. This method also validates whether the value is actually a boolean value.

Parameters

Name Type Description
$name string  
$group string  
$setting string  

Throws

ClassDescription
ezcConfigurationUnknownConfigException if the configuration does not exist.
ezcConfigurationUnknownGroupException if the group does not exist.
ezcConfigurationUnknownSettingException if the setting does not exist.
ezcConfigurationSettingWrongTypeException if the setting value is not a boolean.

See also:

fetchSetting.


getInstance

ezcConfigurationManager getInstance( )
Returns the instance of the class ezcConfigurationManager.

getNumberSetting

int getNumberSetting( string $name, string $group, string $setting )
Returns the value of the setting $setting in group $group in the configuration named $name.
Uses the fetchSetting() method to fetch the value, this method can throw exceptions. This method also validates whether the value is actually an integer value.

Parameters

Name Type Description
$name string  
$group string  
$setting string  

Throws

ClassDescription
ezcConfigurationUnknownConfigException if the configuration does not exist.
ezcConfigurationUnknownGroupException if the group does not exist.
ezcConfigurationUnknownSettingException if the setting does not exist.
ezcConfigurationSettingWrongTypeException if the setting value is not a number.

See also:

fetchSetting.


getSetting

mixed getSetting( string $name, string $group, string $setting )
Returns the value of the setting $setting in group $group in the configuration named $name.
Uses the fetchSetting() method to fetch the value, this method can throw exceptions.

Parameters

Name Type Description
$name string  
$group string  
$setting string  

Throws

ClassDescription
ezcConfigurationUnknownConfigException if the configuration does not exist.
ezcConfigurationUnknownGroupException if the group does not exist.
ezcConfigurationUnknownSettingException if the setting does not exist.

getSettings

array getSettings( string $name, string $group, $settings )
Returns the values of the settings $settings in group $group in the configuration named $name.
For each of the setting names passed in the $settings array it will return the setting in the returned array with the name of the setting as key.

Parameters

Name Type Description
$name string  
$group string  
$settings array  

Throws

ClassDescription
ezcConfigurationUnknownConfigException if the configuration does not exist.
ezcConfigurationUnknownGroupException if the group does not exist.
ezcConfigurationUnknownSettingException if one or more of the settings do not exist.

See also:

ezcConfigurationManager::getSettingsAsList().


getSettingsAsList

array getSettingsAsList( string $name, string $group, $settings )
Returns the values of the settings $settings in group $group as an array.
For each of the setting names passed in the $settings array it will only return the values of the settings in the returned array, and not include the name of the setting as the array's key.

Parameters

Name Type Description
$name string  
$group string  
$settings array  

Throws

ClassDescription
ezcConfigurationUnknownConfigException if the configuration does not exist.
ezcConfigurationUnknownGroupException if the group does not exist.
ezcConfigurationUnknownSettingException if one or more of the settings do not exist.

See also:

ezcConfigurationManager::getSettings().


getStringSetting

string getStringSetting( string $name, string $group, string $setting )
Returns the value of the setting $setting in group $group in the configuration named $name.
Uses the fetchSetting() method to fetch the value, this method can throw exceptions. This method also validates whether the value is actually a string value.

Parameters

Name Type Description
$name string  
$group string  
$setting string  

Throws

ClassDescription
ezcConfigurationUnknownConfigException if the configuration does not exist.
ezcConfigurationUnknownGroupException if the group does not exist.
ezcConfigurationUnknownSettingException if the setting does not exist.
ezcConfigurationSettingWrongTypeException if the setting value is not a string.

See also:

fetchSetting.


hasSetting

bool hasSetting( string $name, string $group, string $setting )
Returns whether the setting $setting exists in group $group in the configuration named $name.

Parameters

Name Type Description
$name string  
$group string  
$setting string  

Throws

ClassDescription
ezcConfigurationUnknownConfigException if the configuration does not exist.

init

void init( string $readerClass, string $location, [ $options = array()] )
Initializes the manager.
Initializes the manager with the values which will be used by the configuration reader. It sets the default location and reader options and which reader to use by specifying the class name.

Parameters

Name Type Description
$readerClass string The name of the class to use as a configuration reader. This class must implement the ezcConfigurationReader interface.
$location string The main placement for the configuration. It is up to the specific reader to interpret this value. This can for instance be used to determine the directory location for an INI file.
$options array Options for the configuration reader, this is passed on the reader specified in $readerClass when it is created. Check the documentation for the specific reader to see which options it supports.

Throws

ClassDescription
ezcConfigurationInvalidReaderClassException if the $readerClass does not exist or does not implement the ezcConfigurationReader interface.

Last updated: Fri, 02 Nov 2007