|
CInbox (Common-Inbox)
0.1
Common functionality for ingesting files for archiving.
|
Public Member Functions | |
| __construct (&$logger, $configFile=null) | |
| initPlaceholders ($arguments=null) | |
| addPlaceholder ($name, $value) | |
| getPlaceholders () | |
| set ($name, $value) | |
| get ($name) | |
| getSettings () | |
| getConfigRaw () | |
| getConfigForSection ($section, $arguments=null) | |
| getFromArray ($section, $name, $arguments=null) | |
| getFromDefault ($name, $arguments=null) | |
| getFromUndefined ($name, $arguments=null) | |
| getConfigForDefault ($arguments=null) | |
| getConfigForUndefined ($arguments=null) | |
| setConfigFile ($configFile=null) | |
| getConfigFile () | |
| hasChanged () | |
| getConfigFileProps () | |
| storeConfigFileProps () | |
| monitorConfigFileChanges () | |
| loadConfigFromFile () | |
| loadConfigFromString ($configString) | |
| parseConfigFromString ($configString) | |
| resolveString ($string, $arguments=null) | |
| getConfigResolved ($arguments=null) | |
| setConfigArray ($configArray) | |
| getConfigArray ($arguments=null) | |
| loadSettings ($config) | |
| setSettingsDefaults ($defaultValues) | |
Public Attributes | |
| const | CONF_SECTION_DEFAULT = '__DEFAULT__' |
| const | CONF_SECTION_UNDEFINED = '__UNDEFINED__' |
Private Attributes | |
| $logger | |
| $configFile = null | |
| $configFileProps = null | |
| $configChanged = null | |
| $configRaw | |
| $configResolved | |
| $configArray | |
| $settings | |
| $placeholders | |
This class manages the Common Inbox configuration. Functions include: loading from file, resolving placeholders, etc.
In the future it can be extended to also write config files.
The correct way to load and initialize the config is:
| CIConfig::addPlaceholder | ( | $name, | |
| $value | |||
| ) |
Adds a new placeholder=value pair to existing placeholder list. Used to add values to be present during resolving of placeholders.
Must be called after 'initPlaceholders()', because otherwise additions to placeholders will be lost.
| CIConfig::get | ( | $name | ) |
Short for "getSetting".
| CIConfig::getConfigFile | ( | ) |
Returns the the currently set config file.
| String | Full path + name of the current config file. Null if config file is not set yet. |
| CIConfig::getConfigFileProps | ( | ) |
Returns the file properties of the config file.
| CIConfig::getConfigForDefault | ( | $arguments = null | ) |
Returns the configuration section for DEFAULT.
| CIConfig::getConfigForSection | ( | $section, | |
$arguments = null |
|||
| ) |
Returns the config block defined within INI section '$section'. $arguments can optionally be provided to resolve placeholders.
| CIConfig::getConfigForUndefined | ( | $arguments = null | ) |
Returns the configuration section for UNDEFINED.
| CIConfig::getConfigRaw | ( | ) |
Returns the raw configuration string. False if configuration has not yet been loaded.
| CIConfig::getConfigResolved | ( | $arguments = null | ) |
This returns the configuration as INI string - after resolving placeholders. It also updates the property: '$this->configResolved'.
Use 'getConfigArray()' to get the INI configuration as associative array.
| CIConfig::getFromArray | ( | $section, | |
| $name, | |||
$arguments = null |
|||
| ) |
Returns a configuration value retrieved from the resolved config array by section + name.
| CIConfig::getFromDefault | ( | $name, | |
$arguments = null |
|||
| ) |
Same as "getFromArray()", but reads from the DEFAULT section.
| CIConfig::getFromUndefined | ( | $name, | |
$arguments = null |
|||
| ) |
Same as "getFromArray()", but reads from the UNDEFINED section.
| CIConfig::getPlaceholders | ( | ) |
Returns the current placeholders array as-is.
| CIConfig::getSettings | ( | ) |
Returns the currently loaded settings as array. Read-only. Do not attempt to write to it.
| CIConfig::hasChanged | ( | ) |
Returns the value of $configChanged.
| CIConfig::initPlaceholders | ( | $arguments = null | ) |
Initializes values for common placeholders, such as date/time values. This allows consistent timestamps across certain execution ranges.
| CIConfig::loadConfigFromFile | ( | ) |
Loads the configuration from a file an stores the contents in raw, unmodified form as string in property '$configRaw'. Resets $configChanged to 'false'.
Triggers storeConfigFileProps() to allow monitoring for runtime changes in config file.
| CIConfig::loadConfigFromString | ( | $configString | ) |
Equivalent to "loadConfigFromFile()", but without the step of reading it from the file.
| CIConfig::loadSettings | ( | $config | ) |
Loads the configuration items from an INI-array into the '$settings' property. The INI-array must not contain multiple sections anymore, but only the content of one section.
Default values must be loaded using 'setSettingsDefaults()' before calling 'loadSettings()' in order to have default values instead of empty values where no setting was configured in config file.
| CIConfig::monitorConfigFileChanges | ( | ) |
Compares the file properties stored in $configFileProps differ from the ones currently loaded. If difference is detected, $configChanged is also set to 'true'.
| boolean | 'false' if no change was detected. 'true' if the config file has changed and should be reloaded. null if $configFileProps are not set yet. storeConfigFileProps() must be run before. |
| CIConfig::parseConfigFromString | ( | $configString | ) |
Parses the configuration in $configString in INI format. Returns the configuration as array as returned from "parse_ini_string" function. It also stores it in property '$configArray';
No placeholders are resolved at this point.
| CIConfig::resolveString | ( | $string, | |
$arguments = null |
|||
| ) |
Resolves a given string using all placeholders known to this config instance.
| CIConfig::set | ( | $name, | |
| $value | |||
| ) |
Short for "setSetting".
| CIConfig::setConfigArray | ( | $configArray | ) |
Sets this item's property 'configArray' to the contents of $configArray.
| Array | $configArray | Configuration as array as returned by "parse_ini_file()". |
| CIConfig::setConfigFile | ( | $configFile = null | ) |
Set the full path and filename of the configuration INI file to be used.
Integrity checks are performed to make sure that $configFile is not empty, that it is actually a file and has size greater than 0.
No checks regarding the contents of the file are performed in this step, however.
| CIConfig::setSettingsDefaults | ( | $defaultValues | ) |
Initialize settings to default values. Call this before loadSettings to provide non-empty values where defaults exists.
WARNING: This overwrites already existing name/value settings.
| CIConfig::storeConfigFileProps | ( | ) |
Updates the file properties of the config file and stores them in $configFileProps.
This is used to monitor the config file during runtime in order to know if settings must be reloaded or not.
| Array | Returns the new contents of $configFileProps. |
1.8.8