Configuration: ezcConfigurationArrayReader
[ ]
[ ]
[ ]
[ ]
[ ]
Class: ezcConfigurationArrayReader
|
This class provides functionality for reading files containing specific PHP arrays into ezcConfiguration objects. [
source]
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.
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();
2. // $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. }
Parents
ezcConfigurationReader
|
--ezcConfigurationFileReader
|
--ezcConfigurationArrayReader
Inherited Member Variables
From
ezcConfigurationFileReader:
Method Summary
Inherited Methods
From
ezcConfigurationFileReader :
From
ezcConfigurationReader :
Methods
getSuffix
string getSuffix(
)
Returns the suffix used in the storage filename.
Redefinition of
load
Loads the current config object
Loads the current config object from a given location which can later be stored with a ezcConfigurationWriter.
Throws
| Class | 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. |
See also:
config().
Redefinition of
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
Last updated: Fri, 02 Nov 2007