Configuration: ezcConfigurationIniReader
[ ]
[ ]
[ ]
[ ]
[ ]
Class: ezcConfigurationIniReader
|
ezcConfigurationIniReader provides functionality for reading INI files into ezcConfiguration objects. [
source]
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.
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. }
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. }
This class uses exceptions and will throw them when the conditions for the operation fails somehow.
Parents
ezcConfigurationReader
|
--ezcConfigurationFileReader
|
--ezcConfigurationIniReader
Inherited Member Variables
From
ezcConfigurationFileReader:
Method Summary
Inherited Methods
From
ezcConfigurationFileReader :
From
ezcConfigurationReader :
Methods
getSuffix
string getSuffix(
)
Returns 'ini'. The suffix used in the storage filename.
Redefinition of
load
Loads a configuration object
Loads the current config object from a give 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. |
ezcConfigurationInvalidSuffixException |
if the current location values cannot be used for reading. |
ezcConfigurationReadFailureException |
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.
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
Last updated: Thu, 03 Jul 2008