Path

ez components / documentation / api reference / 2007.2alpha1 / configuration


eZ Components 2007.2alpha1

Configuration: ezcConfigurationReader

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

Class: ezcConfigurationReader

This class provides the interface for readers of configuration objects of type ezcConfiguration. [source]
The reader will unserialize the data from a given format e.g. from an INI file or a given XML format which can later be written by a ezcConfigurationWriter.
The reader is meant to be initialized with setLocation() and setConfig() and then a call to save(). It is also possible to initialize everything with the init() function.
1.  $reader new ezcConfigurationIniReader();
2.  $reader->init'site''settings' );
3.  $conf $reader->load();
Most readers allows even quicker initialization with the constructor. For instance the INI reader allows you to specify the full path to the INI file.
1.  $reader new ezcConfigurationIniReader'settings/site.ini' );
2.  $conf $reader->load();

Descendents

Child Class Description
ezcConfigurationFileReader ezcConfigurationFileReader class provides the functionality for reading file based configuration formats.

Method Summary

public abstract bool configExists( )
Checks if the configuration exists.
public abstract ezcConfiguration getConfig( )
Returns the current configuration object.
public abstract string getLocation( )
Returns the current location string.
public abstract string getName( )
Returns the name of the configuration to be written.
public abstract array getOptions( )
Returns the options for the reader.
protected abstract string getSuffix( )
Returns the suffix used in the storage filename.
public abstract mixed getTimestamp( )
Returns the last modified timestamp.
public abstract void init( $location, $name, [$options = array()] )
Initializes the reader with a $location and a $name.
public abstract ezcConfiguration load( )
Loads the current config object.
public abstract void setOptions( $options )
Sets the options $options for the reader.
public abstract ezcConfigurationValidationResult validate( [$strict = false] )
Validates the configuration.

Methods

configExists

bool configExists( )
Checks if the configuration exists.
Returns true if a configuration exists at the location specified in the constructor.

Redefined in descendants as

Method Description
ezcConfigurationFileReader::configExists() Returns true if the configuration exists.

getConfig

ezcConfiguration getConfig( )
Returns the current configuration object.
Returns the current configuration object if one is set, false otherwise. The object will be set each time load() is called.

Redefined in descendants as

Method Description
ezcConfigurationFileReader::getConfig() Returns the current configuration object.

getLocation

string getLocation( )
Returns the current location string.

Redefined in descendants as

Method Description
ezcConfigurationFileReader::getLocation() Returns the current location string.

getName

string getName( )
Returns the name of the configuration to be written.

Redefined in descendants as

Method Description
ezcConfigurationFileReader::getName() Returns the current name for the configuration to be read.

getOptions

array getOptions( )
Returns the options for the reader.

Redefined in descendants as

Method Description
ezcConfigurationFileReader::getOptions() Returns the current options for the reader.

getSuffix

string getSuffix( )
Returns the suffix used in the storage filename.

Redefined in descendants as

Method Description
ezcConfigurationIniReader::getSuffix() Returns 'ini'. The suffix used in the storage filename.
ezcConfigurationArrayReader::getSuffix() Returns the suffix used in the storage filename.

getTimestamp

mixed getTimestamp( )
Returns the last modified timestamp.
Returns false if the configuration does not exist.

Redefined in descendants as

Method Description
ezcConfigurationFileReader::getTimestamp() Returns the last modified timestamp.

init

void init( string $location, string $name, [ $options = array()] )
Initializes the reader with a $location and a $name.
These values determine where the configuration will be serialized.

Parameters

Name Type Description
$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.
$name string The name for the configuration. It is up to the specific reader to interpret this value. This can for instance be the basename for the INI file, so a value of 'site' would create a file with name 'site.ini'.
$options array An associative array of options for the reader. Which options to use is determined by the specific reader class.

Redefined in descendants as

Method Description
ezcConfigurationFileReader::init() Initializes the reader with a location and a name. These values determine where the configuration will be serialized.

load

Loads the current config object.
The configuration can stored later with a ezcConfigurationWriter.

Throws

ClassDescription
ezcConfigurationNoConfigException if there is no config object to be read from the location.
ezcConfigurationInvalidSuffixException if the current location values cannot be used for reading.
ezcConfigurationReadFailedException if the configuration could not be read from the given location.

See also:

config().

Redefined in descendants as

Method Description
ezcConfigurationIniReader::load() Loads a configuration object
ezcConfigurationArrayReader::load() Loads the current config object

setOptions

void setOptions( array $options )
Sets the options $options for the reader.
The options will be used the next time the save() method is called.

Parameters

Name Type Description
$options array An associative array of options for the reader. Which options to use is determined by the specific reader class.

Redefined in descendants as

Method Description
ezcConfigurationFileReader::setOptions() Sets the options $configurationData.

validate

ezcConfigurationValidationResult validate( [bool $strict = false] )
Validates the configuration.
Validates the configuration at the given location and returns the validation result.
If $strict is set it will not validate the file if it contains any errors or warnings. If false it will allow warnings but not errors.

Parameters

Name Type Description
$strict bool  

Redefined in descendants as

Method Description
ezcConfigurationIniReader::validate() Validates the configuration.
ezcConfigurationArrayReader::validate() Validates the configuration

Last updated: Mon, 12 Nov 2007