Configuration: ezcConfigurationWriter
[ ]
[ ]
[ ]
[ ]
[ ]
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 class. For
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
getName
string getName(
)
Returns the current name for the configuration to be written.
Redefined in descendants as
getOptions
array getOptions(
)
Returns the current options for the writer.
Redefined in descendants as
getSuffix
string getSuffix(
)
Returns the suffix used in the storage filename.
Redefined in descendants as
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
save
void save(
)
Saves the current config object.
The configuration retrieved later with a ezcConfigurationReader.
Throws
| Class | Description |
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
setConfig
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
Redefined in descendants as
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
Last updated: Mon, 17 Dec 2007