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

### Configuration::ezcConfigurationIniReader

### Class ezcConfigurationIniReader

ezcConfigurationIniReader provides functionality for reading INI files into ezcConfiguration objects.

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

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

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

Or generally use the init() function:

1. $reader=new ezcConfigurationIniReader ();
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. }

Options can be set with the setOptions() method. The only option that this reader supports is the "useComments" option:

1. $reader-> setOptions (array('useComments'=>true) );

Instead of loading the INI file it can be validated with validate(), this will return an ezcConfigurationValidationResult which can be inspected and presented to the end user.

1. $result=$reader-> validate ();
2. if(!$result->isValid)
3. {
4. foreach($result->getResultList()as$resultItem)
5. {
6. print$resultItem-> file.":".$resultItem->line.":".
7. $resultItem->column.":";
8. print" ".$resultItem->details."\n";
9. }
10. }

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.

Source for this file: /Configuration/src/ini/ini_reader.php

    ezcConfigurationReader
       |
       --ezcConfigurationFileReader
          |
          --ezcConfigurationIniReader

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 'ini'. The suffix used in the storage filename.
public ezcConfiguration | `load( )` Loads a configuration 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 'ini'. 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 a configuration object

Loads the current config object from a give 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.
`ezcConfigurationInvalidSuffixException` | if the current location values cannot be used for reading.
`ezcConfigurationReadFailureException` | 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.

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 |

##### Redefinition of:

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

Documentation generated by phpDocumentor 1.4.3