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:
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 )
- {
- }
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.
- if ( !$result->isValid )
- {
- foreach ( $result->getResultList() as $resultItem )
- {
- // ...
- }
- }
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
Returns the suffix used in the storage filename.
Redefinition of:
Method | Description |
---|---|
ezcConfigurationReader::getSuffix() |
Returns the suffix used in the storage filename. |
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
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. |