NewsFeaturesDownloadsDevelopmentSupportAbout Us

ConfigFileStorage Class Reference
[Config]

Inherits ConfigAbstractStorage.

List of all members.


Public Member Functions

 ConfigFileStorage ($params=null)
 reload ()
 getConfigFileName ()
 createConfigFile ($configFileName=null)
 saveValue ($name, $value)
 getValue ($key, $defaultValue=null)
 setValue ($key, $value)
 getKeys ()
 getValues ()
 getAsArray ()
 save ()

Public Attributes

 $_configFile
 $_props

Private Member Functions

 _getDataString ($data)

Detailed Description

Implements a file-based configuration backend. The data in the file has to be arranged in a php array called $config, in the same way the file config/config.properties.php is arranged.

The backend will use the array keys as its own keys and the values as its own values, and will take care of serializing and unserializing data as needed (so that we can for example save Objects and Arrays to the config file)

Definition at line 19 of file configfilestorage.class.php.


Member Function Documentation

ConfigFileStorage.ConfigFileStorage ( params = null  ) 

Opens the configuration file. By default it is config/config.properties.php if no parameter is specified. If there is a parameter specified, that is the file the constructor will try to open. If no file name is specified, it defaults to config/config.properties.php.

Parameters:
configFile The name of the file we would like to use.

Definition at line 33 of file configfilestorage.class.php.

References $params, ConfigAbstractStorage.ConfigAbstractStorage(), and reload().

ConfigFileStorage.reload (  ) 

Reloads the contents from the configuration file.

Returns:
Returns true if successul or false otherwise

Reimplemented from ConfigAbstractStorage.

Definition at line 53 of file configfilestorage.class.php.

References $config, $result, File.isReadable(), and lt_include().

Referenced by ConfigFileStorage().

ConfigFileStorage.getConfigFileName (  ) 

Returns the name of the configuration file being used.

Returns:
The name of the configuration file being used.

Reimplemented from ConfigAbstractStorage.

Definition at line 75 of file configfilestorage.class.php.

ConfigFileStorage.createConfigFile ( configFileName = null  ) 

Create a new config file from scratch.

$return true if config file could be created, false otherwise

Definition at line 85 of file configfilestorage.class.php.

References $file, and lt_include().

ConfigFileStorage._getDataString ( data  )  [private]

Private function that given a piece of PHP data, will return an string representing it, literally. Examples:

data is a boolean type. Result --> the string 'true' data is string type. Result --> string "value_of_the_string" data is an array. Result --> string containing "Array( "..", "...", "..") "

Objects are saved serialized and since there is no way to detect if it's an object or not, it will be up to the user of the class to de-serialize it.

:TODO: This function does not handle very well sparse arrays, but it does handles arrays within arrays.

Parameters:
data The data we'd like to get the string representation
Returns:
An string representing the data, so that eval'ing it would yield the the same result as the $data parameter.

Definition at line 139 of file configfilestorage.class.php.

References $data, and ConfigAbstractStorage._getType().

Referenced by saveValue().

ConfigFileStorage.saveValue ( name,
value 
)

Saves a setting to the configuration file. If the setting already exists, the current value is overwritten. Otherwise, it will be appended in the end of the file. NOTE: This method is highly unoptimized because every time that we call saveValue, we are writing the whole file to disk... Bad ;) But it works, so we'll leave it as it is for the time being...

Parameters:
name Name of the setting.
value Value of the setting.
Returns:
True if success or false otherwise.

Reimplemented from ConfigAbstractStorage.

Definition at line 189 of file configfilestorage.class.php.

References $i, $regexp, $result, _getDataString(), ConfigAbstractStorage._getType(), and lt_include().

Referenced by save().

ConfigFileStorage.getValue ( key,
defaultValue = null 
)

Given a key, gets its value from the storage backend.

Parameters:
key The key that we're looking for
defaultValue Optional, if the key does not exist we can provide a second parameter that will be returned as the default value
Returns:
The value assigned to the key or $defaultValue if there was no such key found

Reimplemented from ConfigAbstractStorage.

Definition at line 248 of file configfilestorage.class.php.

ConfigFileStorage.setValue ( key,
value 
)

See also:
ConfigAbstractStorage.setValue()

Reimplemented from ConfigAbstractStorage.

Definition at line 261 of file configfilestorage.class.php.

ConfigFileStorage.getKeys (  ) 

See also:
ConfigAbstractStorage.getKeys()

Reimplemented from ConfigAbstractStorage.

Definition at line 269 of file configfilestorage.class.php.

ConfigFileStorage.getValues (  ) 

See also:
ConfigAbstractStorage.getValues()

Reimplemented from ConfigAbstractStorage.

Definition at line 277 of file configfilestorage.class.php.

ConfigFileStorage.getAsArray (  ) 

See also:
ConfigAbstractStorage.getAsArray()

Reimplemented from ConfigAbstractStorage.

Definition at line 285 of file configfilestorage.class.php.

ConfigFileStorage.save (  ) 

See also:
ConfigAbstractStorage.save()

Reimplemented from ConfigAbstractStorage.

Definition at line 293 of file configfilestorage.class.php.

References saveValue().


Member Data Documentation

ConfigFileStorage.$_configFile

Definition at line 22 of file configfilestorage.class.php.

ConfigFileStorage.$_props

Definition at line 23 of file configfilestorage.class.php.