Zeta Components Manual :: Docs For Class ezcConfigurationReader
Configuration::ezcConfigurationReader
Class ezcConfigurationReader
This class provides the interface for readers of configuration objects of type ezcConfiguration.
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.
Source for this file: /Configuration/src/interfaces/reader.php
Version: | //autogen// |
Descendants
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 read. |
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
Checks if the configuration exists.
Returns true if a configuration exists at the location specified in the constructor.
Redefined in descendants as:
Method | Description |
---|---|
ezcConfigurationFileReader::configExists() |
Returns true if the configuration exists. |
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:
Method | Description |
---|---|
ezcConfigurationFileReader::getConfig() |
Returns the current configuration object. |
getLocation
Returns the current location string.
Redefined in descendants as:
Method | Description |
---|---|
ezcConfigurationFileReader::getLocation() |
Returns the current location string. |
getName
Returns the name of the configuration to be read.
Redefined in descendants as:
Method | Description |
---|---|
ezcConfigurationFileReader::getName() |
Returns the current name for the configuration to be read. |
getOptions
Returns the options for the reader.
Redefined in descendants as:
Method | Description |
---|---|
ezcConfigurationFileReader::getOptions() |
Returns the current options for the reader. |
getSuffix
Returns the suffix used in the storage filename.
Redefined in descendants as:
Method | Description |
---|---|
ezcConfigurationArrayReader::getSuffix() |
Returns the suffix used in the storage filename. |
ezcConfigurationIniReader::getSuffix() |
Returns 'ini'. The suffix used in the storage filename. |
getTimestamp
Returns the last modified timestamp.
Returns false if the configuration does not exist.
Redefined in descendants as:
Method | Description |
---|---|
ezcConfigurationFileReader::getTimestamp() |
Returns the last modified timestamp. |
init
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.
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. |
ezcConfigurationReadFailedException |
if the configuration could not be read from the given location. |
Redefined in descendants as:
Method | Description |
---|---|
ezcConfigurationArrayReader::load() |
Loads the current config object |
ezcConfigurationIniReader::load() |
Loads a configuration object |
setOptions
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:
Method | Description |
---|---|
ezcConfigurationFileReader::setOptions() |
Sets the options $configurationData. |
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:
Method | Description |
---|---|
ezcConfigurationArrayReader::validate() |
Validates the configuration |
ezcConfigurationIniReader::validate() |
Validates the configuration. |