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

### Configuration::ezcConfigurationArrayReader

### Class ezcConfigurationArrayReader

This class provides functionality for reading files containing specific PHP arrays into ezcConfiguration objects.

The file it reads from must be a PHP file containing the group and comments (if enabled).

A typical usage is to create the reader object and pass the filepath in the constructor:

1. $reader=new ezcConfigurationArrayReader ("settings/site.php");
2. $reader-> load ();

That makes the class figure out the location and name values automatically.

Or generally use the init() function:

1. $reader=new ezcConfigurationArrayReader ();
2. $reader-> init ("settings","site");
3. $reader-> load ();

Accessing the configuration object is done by the getConfig() method or by using the return value of load():

1. $conf1=$reader-> load ();
2. $conf2=$reader-> getConfig ();
3. // $conf1 and $conf2 points to the same object

If caching is employed the getTimestamp() method can be used to find the last modification time of the file.

1. $time=$reader-> getTimestamp ();
2. if($time>$cachedTime)
3. {
4. $reader-> load ();
5. }

Instead of loading the PHP file it can be validated with validate(), this will return an ezcConfigurationValidationResult which can be inspected and presented to the end user. As the array format can never have any parse errors per line, the validation result will always be empty.

1. $result=$reader-> validate ();
2. if(!$result->isValid)
3. {
4. foreach($result->getResultList()as$resultItem)
5. {
6. // ...
7. }
8. }

For more information on file based configurations see ezcConfigurationFileReader.

This class uses exceptions and will throw them when the conditions for the operation fails somehow.

Files are required to have the suffix .php, as this allows PHP accelerators to cache the content for even faster retrieval.

Source for this file: /Configuration/src/array/array_reader.php

    ezcConfigurationReader
       |
       --ezcConfigurationFileReader
          |
          --ezcConfigurationArrayReader

Version: | //autogen//

### Inherited Member Variables

From ezcConfigurationFileReader
protected | `ezcConfigurationFileReader::$config`
protected | `ezcConfigurationFileReader::$location`
protected | `ezcConfigurationFileReader::$name`
protected | `ezcConfigurationFileReader::$options`
protected | `ezcConfigurationFileReader::$path`

### Method Summary

protected string | `getSuffix( )` Returns the suffix used in the storage filename.
public ezcConfiguration | `load( )` Loads the current config object
public ezcConfigurationValidationResult | `validate( [ $strict = false] )` Validates the configuration

### Inherited Methods

From ezcConfigurationFileReader
public ezcConfigurationFileReader | `ezcConfigurationFileReader::__construct()` Constructs the reader object.
public bool | `ezcConfigurationFileReader::configExists()` Returns true if the configuration exists.
public ezcConfiguration | `ezcConfigurationFileReader::getConfig()` Returns the current configuration object.
public string | `ezcConfigurationFileReader::getLocation()` Returns the current location string.
public string | `ezcConfigurationFileReader::getName()` Returns the current name for the configuration to be read.
public array | `ezcConfigurationFileReader::getOptions()` Returns the current options for the reader.
public int | `ezcConfigurationFileReader::getTimestamp()` Returns the last modified timestamp.
public void | `ezcConfigurationFileReader::init()` Initializes the reader with a location and a name. These values determine where the configuration will be serialized.
protected void | `ezcConfigurationFileReader::parseLocationPath()` Parses a the path $path and sets the location and name properties on this object.
public void | `ezcConfigurationFileReader::setOptions()` Sets the options $configurationData.
From ezcConfigurationReader
public abstract bool | `ezcConfigurationReader::configExists()` Checks if the configuration exists.
public abstract ezcConfiguration | `ezcConfigurationReader::getConfig()` Returns the current configuration object.
public abstract string | `ezcConfigurationReader::getLocation()` Returns the current location string.
public abstract string | `ezcConfigurationReader::getName()` Returns the name of the configuration to be read.
public abstract array | `ezcConfigurationReader::getOptions()` Returns the options for the reader.
protected abstract string | `ezcConfigurationReader::getSuffix()` Returns the suffix used in the storage filename.
public abstract mixed | `ezcConfigurationReader::getTimestamp()` Returns the last modified timestamp.
public abstract void | `ezcConfigurationReader::init()` Initializes the reader with a $location and a $name.
public abstract ezcConfiguration | `ezcConfigurationReader::load()` Loads the current config object.
public abstract void | `ezcConfigurationReader::setOptions()` Sets the options $options for the reader.
public abstract ezcConfigurationValidationResult | `ezcConfigurationReader::validate()` Validates the configuration.

### Methods

#### getSuffix

string getSuffix( )

Returns the suffix used in the storage filename.

##### Redefinition of:

Method | Description
--- | ---
`ezcConfigurationReader::getSuffix()` | Returns the suffix used in the storage filename.

#### load

ezcConfiguration load( )

Loads the current config object

Loads the current config object from a given location which can later be stored with a ezcConfigurationWriter.

##### Exceptions:

Type | Description
--- | ---
`ezcConfigurationNoConfigException` | if there is no config object to be read from the location.
`ezcConfigurationInvalidSuffix` | if the current location values cannot be used for reading.
`ezcConfigurationReadFailedException` | if the configuration could not be read from the given location.

##### Redefinition of:

Method | Description
--- | ---
`ezcConfigurationReader::load()` | Loads the current config object.

#### validate

ezcConfigurationValidationResult validate( [bool $strict = false] )

Validates the configuration

Validates the configuration at the given location and returns the validation result.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$strict` | bool | Controls how strict the validation is. If set to true it will not validate the file if it contains any errors or warnings. If false it will allow warnings but not errors.

##### Redefinition of:

Method | Description
--- | ---
`ezcConfigurationReader::validate()` | Validates the configuration.

Documentation generated by phpDocumentor 1.4.3