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// |
Child Class | Description |
---|---|
ezcConfigurationFileReader | ezcConfigurationFileReader class provides the functionality for reading file based configuration formats. |
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. |
Checks if the configuration exists.
Returns true if a configuration exists at the location specified in the constructor.
Method | Description |
---|---|
ezcConfigurationFileReader::configExists() |
Returns true if the configuration exists. |
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.
Method | Description |
---|---|
ezcConfigurationFileReader::getConfig() |
Returns the current configuration object. |
Returns the current location string.
Method | Description |
---|---|
ezcConfigurationFileReader::getLocation() |
Returns the current location string. |
Returns the name of the configuration to be read.
Method | Description |
---|---|
ezcConfigurationFileReader::getName() |
Returns the current name for the configuration to be read. |
Returns the options for the reader.
Method | Description |
---|---|
ezcConfigurationFileReader::getOptions() |
Returns the current options for the reader. |
Returns the suffix used in the storage filename.
Method | Description |
---|---|
ezcConfigurationArrayReader::getSuffix() |
Returns the suffix used in the storage filename. |
ezcConfigurationIniReader::getSuffix() |
Returns 'ini'. The suffix used in the storage filename. |
Returns the last modified timestamp.
Returns false if the configuration does not exist.
Method | Description |
---|---|
ezcConfigurationFileReader::getTimestamp() |
Returns the last modified timestamp. |
Initializes the reader with a $location and a $name.
These values determine where the configuration will be serialized.
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. |
Method | Description |
---|---|
ezcConfigurationFileReader::init() |
Initializes the reader with a location and a name. These values determine where the configuration will be serialized. |
Loads the current config object.
The configuration can stored later with a ezcConfigurationWriter.
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. |
Method | Description |
---|---|
ezcConfigurationArrayReader::load() |
Loads the current config object |
ezcConfigurationIniReader::load() |
Loads a configuration object |
Sets the options $options for the reader.
The options will be used the next time the save() method is called.
Name | Type | Description |
---|---|---|
$options |
array | An associative array of options for the reader. Which options to use is determined by the specific reader class. |
Method | Description |
---|---|
ezcConfigurationFileReader::setOptions() |
Sets the options $configurationData. |
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.
Name | Type | Description |
---|---|---|
$strict |
bool |
Method | Description |
---|---|
ezcConfigurationArrayReader::validate() |
Validates the configuration |
ezcConfigurationIniReader::validate() |
Validates the configuration. |