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) | |
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.
| 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.
| 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.
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.
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.
| data | The data we'd like to get the string representation |
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...
| name | Name of the setting. | |
| value | Value of the setting. |
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.
| 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 |
Reimplemented from ConfigAbstractStorage.
Definition at line 248 of file configfilestorage.class.php.
| ConfigFileStorage.setValue | ( | $ | key, | |
| $ | value | |||
| ) |
Reimplemented from ConfigAbstractStorage.
Definition at line 261 of file configfilestorage.class.php.
| ConfigFileStorage.getKeys | ( | ) |
Reimplemented from ConfigAbstractStorage.
Definition at line 269 of file configfilestorage.class.php.
| ConfigFileStorage.getValues | ( | ) |
Reimplemented from ConfigAbstractStorage.
Definition at line 277 of file configfilestorage.class.php.
| ConfigFileStorage.getAsArray | ( | ) |
Reimplemented from ConfigAbstractStorage.
Definition at line 285 of file configfilestorage.class.php.
| ConfigFileStorage.save | ( | ) |
Reimplemented from ConfigAbstractStorage.
Definition at line 293 of file configfilestorage.class.php.
References saveValue().
| ConfigFileStorage.$_configFile |
Definition at line 22 of file configfilestorage.class.php.
| ConfigFileStorage.$_props |
Definition at line 23 of file configfilestorage.class.php.