## Apache Zeta Components Manual :: Docs For Class ezcConfigurationWriter

### Configuration::ezcConfigurationWriter

### Class ezcConfigurationWriter

This class provides the interface for writers of configuration objects of type ezcConfiguration.

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>
7. Classes thatimplementsthisinterfaceare adviced to create a constructor with
8. all the initializationasparameter to make it easier tousetheclass.For
9. instance this could transform the above example into:
11. <code>
12. $writer=newezcConfigurationIniWriter($conf,'site','settings');
13. $writer->save();

Source for this file: /Configuration/src/interfaces/writer.php

Version: | //autogen//

### Descendants

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
--- | ---
`ezcConfigurationArrayWriter::getSuffix()` | Returns the suffix used in the storage filename.
`ezcConfigurationIniWriter::getSuffix()` | Returns 'ini'. 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.

##### Exceptions:

Type | Description
--- | ---
`ezcConfigurationReadFailedException` | if the configuration could not be written to the given location.
`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.

##### 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.

Documentation generated by phpDocumentor 1.4.3