Configuration: ezcConfigurationFileReader
[ ]
[ ]
[ ]
[ ]
[ ]
Class: ezcConfigurationFileReader
|
ezcConfigurationFileReader class provides the functionality for reading file based configuration formats. [
source]
This class implements most of the interface of ezcConfigurationReader and makes it easier to work on file based configuration. All methods except load() and validate() are implemented by this class, so a subclass only needs to handle the actual serialization.
Parents
ezcConfigurationReader
|
--ezcConfigurationFileReader
Descendents
| Child Class |
Description |
| ezcConfigurationIniReader |
ezcConfigurationIniReader provides functionality for reading INI files into ezcConfiguration objects.
|
| ezcConfigurationArrayReader |
This class provides functionality for reading files containing specific PHP arrays into ezcConfiguration objects.
|
Member Variables
|
protected ezcConfiguration |
$config
= false
Contains the configuration object that was read from the file with load(). |
|
protected string |
$location
= ''
The current location of the config, this is either the path on the filesystem or a PHP stream prefix. |
|
protected string |
$name
= ''
The base name of the configuration file, the suffix will be appended to this to find the real filename. |
|
protected array |
$options
= array()
Current options for the reader. |
|
protected string |
$path
= ''
The path to the file which will contain the serialized configuration data. |
Method Summary
|
public ezcConfigurationFileReader |
__construct(
[$path = null] )
Constructs the reader object. |
|
public bool |
configExists(
)
Returns true if the configuration exists. |
|
public ezcConfiguration |
getConfig(
)
Returns the current configuration object. |
|
public string |
getLocation(
)
Returns the current location string. |
|
public string |
getName(
)
Returns the current name for the configuration to be read. |
|
public array |
getOptions(
)
Returns the current options for the reader. |
|
public int |
getTimestamp(
)
Returns the last modified timestamp. |
|
public void |
init(
$location, $name, [$options = array()] )
Initializes the reader with a location and a name. These values determine where the configuration will be serialized. |
|
protected void |
parseLocationPath(
$path, $suffix )
Parses a the path $path and sets the location and name properties on this object. |
|
public void |
setOptions(
$configurationData )
Sets the options $configurationData. |
Inherited Methods
From
ezcConfigurationReader :
Methods
__construct
ezcConfigurationFileReader __construct(
[string
$path = null] )
Constructs the reader object.
$path must contain the relative or absolute path to the configuration file. You can use PHP streams, e.g compress.gz://site.ini.gz.
After construction call load() to parse the INI file from disk and return a configuration object.
Parameters
| Name |
Type |
Description |
$path |
string |
|
configExists
bool configExists(
)
Returns true if the configuration exists.
Redefinition of
getConfig
Returns the current configuration object.
Returns false if there no current configuration.
Redefinition of
getLocation
string getLocation(
)
Returns the current location string.
Redefinition of
getName
string getName(
)
Returns the current name for the configuration to be read.
Redefinition of
getOptions
array getOptions(
)
Returns the current options for the reader.
Redefinition of
getTimestamp
int getTimestamp(
)
Returns the last modified timestamp.
Returns false if there is not last current timestamp.
Redefinition of
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. |
Redefinition of
parseLocationPath
void parseLocationPath(
string
$path, string
$suffix )
Parses a the path $path and sets the location and name properties on this object.
Parameters
| Name |
Type |
Description |
$path |
string |
|
$suffix |
string |
|
Throws
| Class | Description |
ezcConfigurationException |
if the configuration file has the wrong suffix. |
See also:
ezcConfigurationFileWriter::parseLocationPath() which is the same
code. It is duplicated to prevent complex OO hacks..
setOptions
void setOptions(
array(string=>mixed)
$configurationData )
Sets the options $configurationData.
The options are specified in a associative array in the form 'optionName' => value.
Parameters
| Name |
Type |
Description |
$configurationData |
array(string=>mixed) |
|
Throws
| Class | Description |
ezcBaseSettingNotFoundException |
if you try to set a non existent setting. |
ezcBaseSettingValueException |
if you specify a value out of range for a setting. |
Redefinition of
Last updated: Fri, 02 Nov 2007