|
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) | |
| 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) | |
| 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__' |
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::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.
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.
Returns the currently loaded settings as array. Read-only. Do not attempt to write to it.
| CIConfig::initPlaceholders | ( | $ | arguments = null | ) |
Initializes values for common placeholders, such as date/time values. This allows consistent timestamps across certain execution ranges.
Loads the configuration from a file an stores the contents in raw, unmodified form as string in property '$configRaw'.
| 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::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.
1.7.6.1