Path

ez components / documentation / api reference / 2008.2.3 / configuration


eZ Components 2008.2.3

Configuration: ezcConfigurationWriter

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

Class: ezcConfigurationWriter

This class provides the interface for writers of configuration objects of type ezcConfiguration. [source]
The writer will serialize the data to a given format e.g. to an INI file or a given XML format which can later be read by a ezcConfigurationReader.
The writer 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.  $writer new ezcConfigurationIniWriter();
 2.  $writer->setConfig$configrationObject );
 3.  $writer->setLocation'site''settings' );
 4.  $writer->save();
 5.  <code>
 6.  
 7.  Classes that implements this interface are adviced to create a constructor with
 8.  all the initialization as parameter to make it easier to use the classFor
 9.  instance this could transform the above example into:
10.  
11.  <code>
12.  $writer new ezcConfigurationIniWriter$conf'site''settings' );
13.  $writer->save();

Descendents

Child Class Description
ezcConfigurationFileWriter ezcConfigurationFileWriter class provides the functionality for writing file based configuration formats.

Method Summary

public abstract string getLocation( )
Returns the current location string.
public abstract string getName( )
Returns the current name for the configuration to be written.
public abstract array getOptions( )
Returns the current options for the writer.
protected abstract string getSuffix( )
Returns the suffix used in the storage filename.
public abstract void init( $location, $name, $config, [$options = array()] )
Initializes the writer with a $location and a $name.
public abstract void save( )
Saves the current config object.
public abstract void setConfig( $config )
Sets the configuration object that will be used for the next call to save().
public abstract void setOptions( $options )
Sets the options for the writer.

Methods

getLocation

string getLocation( )
Returns the current location string.

Redefined in descendants as

Method Description
ezcConfigurationFileWriter::getLocation() Return the current location string.

getName

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

Redefined in descendants as

Method Description
ezcConfigurationFileWriter::getName() Return the current name for the configuration to be written.

getOptions

array getOptions( )
Returns the current options for the writer.

Redefined in descendants as

Method Description
ezcConfigurationFileWriter::getOptions() Returns the current options for the writer.

getSuffix

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

Redefined in descendants as

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

init

void init( string $location, string $name, ezcConfiguration $config, [array $options = array()] )
Initializes the writer with a $location and a $name.
These values determine where the configuration will be serialized.
The location string can be used to determine the directory location for an INI file.
The name parameter can be the basename for the INI file, so a value of 'site' would create a file with name 'site.ini'.

Parameters

Name Type Description
$location string The main placement for the configuration. It is up to the specific writer to interpret this value.
$name string The name for the configuration. It is up to the specific writer to interpret this value. For a file writer it could be the basename for the INI file, so a value of 'site' would create a file with name 'site.ini'.
$config ezcConfiguration The current configuration object which should be serialized by the current writer.
$options array An associative array of options for the writer. Which options to use is determined by the specific writer class.

Redefined in descendants as

Method Description
ezcConfigurationFileWriter::init() Initializes the writer with a $location and a $name.

save

void save( )
Saves the current config object.
The configuration retrieved later with a ezcConfigurationReader.

Throws

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

Redefined in descendants as

Method Description
ezcConfigurationFileWriter::save() Saves the current config object.

setConfig

void setConfig( ezcConfiguration $config )
Sets the configuration object that will be used for the next call to save().
Pass false if you wish to remove the current configuration object.

Parameters

Name Type Description
$config ezcConfiguration  

Redefined in descendants as

Method Description
ezcConfigurationFileWriter::setConfig() Sets the configuration object that will be used for the next call to save().

setOptions

void setOptions( array $options )
Sets the options for the writer.
The options will be used the next time the save() method is called. The $options array is an associative array with the options for the writer. It depends on the specific writer which options are allowed here.

Parameters

Name Type Description
$options array  

Redefined in descendants as

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

Last updated: Mon, 11 May 2009