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:
Or generally use the init() function:
Accessing the configuration object is done by the getConfig() method or by using the return value of load():
- // $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.
- if ( $time > $cachedTime )
- {
- }
Options can be set with the setOptions() method. The only option that this reader supports is the "useComments" option:
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.
- if ( !$result->isValid )
- {
- foreach ( $result->getResultList() as $resultItem )
- {
- $resultItem->column. ":";
- print " " . $resultItem->details . "\n";
- }
- }
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
Returns 'ini'. The suffix used in the storage filename.
Redefinition of:
Method | Description |
---|---|
ezcConfigurationReader::getSuffix() |
Returns the suffix used in the storage filename. |
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
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. |