Table of Contents
ConfigFile
The class ConfigFile allows to load and store configuration values.
All settings are stored in .ini files in the directory /etc/nas/sm/services/.
Methods
| Name | Parameter | Return value | Description |
|---|---|---|---|
| loadConfig | String name [optional] | Loads the configuration file of the current service or the file of the specified parameter | |
| storeConfig | String name [optional] | Stores the configuration in the file of the current service or in the file of the specified parameter | |
| getValue | String key | Object | Returns the value of $key |
| setValue | String key, Object val | Sets the value of $key to $val | |
| setValues | Array arr | Sets multiple values at once. The parameter is an associative array like $_POST | |
| setSectionValue | String section, String key, Object val | Sets the value of $key to $val in the ini section $section | |
| createJSONResult | Creates a JSONResult object of the current config object | ||
| toString | Creates and prints a JSONResult object of the current config object |
Examples
$cf = new ConfigFile(); // Loads the configuration file of the current service $cf->loadConfig(); // Transforms the configuration file to a JSONResult and sends the object to the browser echo $cf;
$cf = new ConfigFile(); $cf->setValues($_POST); $cf->setValue('listbox', array('first', 'second', 'third')); $cf->setSectionValue('datarealm', 'listbox', array('First entry', 'Second entry', 'Third entry')); $cf->storeConfig();
Links
You could leave a comment if you were logged in.