Configuration: ezcConfigurationReader
[ ]
[ ]
[ ]
[ ]
[ ]
Class: ezcConfigurationReader
|
This class provides the interface for readers of configuration objects of type ezcConfiguration. [
source]
The reader will unserialize the data from a given format e.g. from an INI file or a given XML format which can later be written by a ezcConfigurationWriter.
The reader is meant to be initialized with setLocation() and setConfig() and then a call to save(). It is also possible to initialize everything with the init() function.
Most readers allows even quicker initialization with the constructor. For instance the INI reader allows you to specify the full path to the INI file.
Descendents
| Child Class |
Description |
| ezcConfigurationFileReader |
ezcConfigurationFileReader class provides the functionality for reading file based configuration formats.
|
Method Summary
|
public abstract bool |
configExists(
)
Checks if the configuration exists. |
|
public abstract ezcConfiguration |
getConfig(
)
Returns the current configuration object. |
|
public abstract string |
getLocation(
)
Returns the current location string. |
|
public abstract string |
getName(
)
Returns the name of the configuration to be written. |
|
public abstract array |
getOptions(
)
Returns the options for the reader. |
|
protected abstract string |
getSuffix(
)
Returns the suffix used in the storage filename. |
|
public abstract mixed |
getTimestamp(
)
Returns the last modified timestamp. |
|
public abstract void |
init(
$location, $name, [$options = array()] )
Initializes the reader with a $location and a $name. |
|
public abstract ezcConfiguration |
load(
)
Loads the current config object. |
|
public abstract void |
setOptions(
$options )
Sets the options $options for the reader. |
|
public abstract ezcConfigurationValidationResult |
validate(
[$strict = false] )
Validates the configuration. |
Methods
configExists
bool configExists(
)
Checks if the configuration exists.
Returns true if a configuration exists at the location specified in the constructor.
Redefined in descendants as
getConfig
Returns the current configuration object.
Returns the current configuration object if one is set, false otherwise. The object will be set each time load() is called.
Redefined in descendants as
getLocation
string getLocation(
)
Returns the current location string.
Redefined in descendants as
getName
string getName(
)
Returns the name of the configuration to be written.
Redefined in descendants as
getOptions
array getOptions(
)
Returns the options for the reader.
Redefined in descendants as
getSuffix
string getSuffix(
)
Returns the suffix used in the storage filename.
Redefined in descendants as
getTimestamp
mixed getTimestamp(
)
Returns the last modified timestamp.
Returns false if the configuration does not exist.
Redefined in descendants as
init
void init(
string
$location, string
$name, [
$options = array()] )
Initializes the reader with a $location and a $name.
These values determine where the configuration will be serialized.
Parameters
| Name |
Type |
Description |
$location |
string |
The main placement for the configuration. It is up to the specific reader to interpret this value. This can for instance be used to determine the directory location for an INI file. |
$name |
string |
The name for the configuration. It is up to the specific reader to interpret this value. This can for instance be the basename for the INI file, so a value of 'site' would create a file with name 'site.ini'. |
$options |
array |
An associative array of options for the reader. Which options to use is determined by the specific reader class. |
Redefined in descendants as
| Method |
Description |
ezcConfigurationFileReader::init() |
Initializes the reader with a location and a name. These values determine where the configuration will be serialized. |
load
Loads the current config object.
The configuration can stored later 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. |
ezcConfigurationReadFailedException |
if the configuration could not be read from the given location. |
See also:
config().
Redefined in descendants as
setOptions
void setOptions(
array
$options )
Sets the options $options for the reader.
The options will be used the next time the save() method is called.
Parameters
| Name |
Type |
Description |
$options |
array |
An associative array of options for the reader. Which options to use is determined by the specific reader class. |
Redefined in descendants as
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 |
|
Redefined in descendants as
Last updated: Tue, 02 Dec 2008