|
Erebot
latest
A modular IRC bot for PHP 5.3+
|
A configuration proxy which cascades settings. More...
Inheritance diagram for Erebot\Config\Proxy:Public Member Functions | |
| __clone () | |
| __destruct () | |
| getMainCfg () | |
| getModule ($moduleName) | |
| getModules ($recursive) | |
| getTranslator ($component) | |
| parseBool ($module, $param, $default=null) | |
| parseInt ($module, $param, $default=null) | |
| parseReal ($module, $param, $default=null) | |
| parseString ($module, $param, $default=null) | |
Static Public Member Functions | |
| static | parseBoolHelper ($value) |
| static | parseIntHelper ($value) |
| static | parseRealHelper ($value) |
Protected Member Functions | |
| __construct (\Erebot\Interfaces\Config\Proxy $proxified,\SimpleXMLElement $xml) | |
| parseSomething ($module, $param, $default,\Erebot\CallableInterface $parser, $origin,\Erebot\CallableInterface $checker) | |
Protected Attributes | |
| $locale | |
| The current locale. | |
| $modules | |
| Array of modules loaded at this particular configuration level. | |
| $proxified | |
| Reference to a proxified object. | |
A configuration proxy which cascades settings.
This class is used to build a hierarchy of configurations. Each level in this hierarchy may override settings applied at upper levels. If no override has been made on some setting, that setting retains the value it had on the preceding level. This allows settings to be cascaded in the hierarchy of configuration levels.
The root of the hierarchy acts as a proxy for itself and always implements Erebot::Interfaces::Config::Main.
|
protected |
Creates a new Erebot::Proxy::Config object.
| Erebot::Interfaces::Config::Proxy | $proxified | A configuration object which should be proxied through this instance. This allows settings to be cascaded. |
| SimpleXMLElement | $xml | An XML node which should be used as the basis for configuration. |
Definition at line 58 of file Proxy.php.
References Erebot\Config\Proxy\$proxified.
| Erebot\Config\Proxy::__destruct | ( | ) |
| Erebot\Config\Proxy::getMainCfg | ( | ) |
Returns the root configuration associated with this hierarchy of configurations.
| Erebot::Interfaces::Config::Main | The main configuration of the bot. |
| Erebot\Config\Proxy::getModule | ( | $moduleName | ) |
Returns the instance of the module configuration with the given name.
| string | $moduleName | Name of the module whose configuration we're insterested in. |
| Erebot::Interfaces::Config::Module | Instance of the module's configuration. |
| ErebotNotFoundException |
| Erebot\Config\Proxy::getModules | ( | $recursive | ) |
Returns a list with the names of all currently active modules.
| bool | $recursive | If set to TRUE, the list is retrieved recursively by merging the lists obtained at this level and all levels above it. If set to FALSE, only the modules activated at this particular level are returned. |
| list(string) | A list with the names of currently active modules. |
| Erebot\Config\Proxy::getTranslator | ( | $component | ) |
Returns the appropriate i18n object to use for translations at this configuration level.
| string | $component | Name of the component we're interested in. This should be set to the name of a module or "Erebot" for the core translator. |
| Erebot::IntlInterface | A translator object. |
| Erebot::NotFoundException | No appropriate translator exists for this configuration level. |
Definition at line 103 of file Proxy.php.
References Erebot\IntlInterface\LC_MESSAGES, Erebot\IntlInterface\LC_MONETARY, Erebot\IntlInterface\LC_NUMERIC, and Erebot\IntlInterface\LC_TIME.
| Erebot\Config\Proxy::parseBool | ( | $module, | |
| $param, | |||
$default = null |
|||
| ) |
Returns the boolean value for a setting in some module.
| string | $module | The name of the module from which to retrieved the setting. |
| string | $param | The name of the parameter we are interested in. |
| bool | $default | (optional) A default value in case no value has been set at the configuration level. |
| bool | The boolean value for that particular module and parameter. |
| Erebot::NotFoundException | The given $module or $param name could not be found. |
| Erebot::InvalidValueException | A value could be retrieved, but its type is not the one we expected (it was NOT a boolean). Either the configuration file contains an invalid value, or no value has been defined in the configuration file and the $default value is invalid. |
Definition at line 352 of file Proxy.php.
References Erebot\Config\Proxy\parseSomething(), and Erebot\CallableWrapper\wrap().
Referenced by Erebot\Config\Main\load().
|
static |
Parses a text and tries to extract a boolean value.
| string | $value | The text from which a boolean should be extracted. |
| bool | If a boolean could be extracted from the $value provided, it is returned as the corresponding PHP boolean value (either true or false). |
| null | No boolean could be extracted. |
| Erebot\Config\Proxy::parseInt | ( | $module, | |
| $param, | |||
$default = null |
|||
| ) |
Returns the integer value for a setting in some module.
| string | $module | The name of the module from which to retrieved the setting. |
| string | $param | The name of the parameter we are interested in. |
| int | $default | (optional) A default value in case no value has been set at the configuration level. |
| int | The interger value for that particular module and parameter. |
| Erebot::NotFoundException | The given $module or $param name could not be found. |
| Erebot::InvalidValueException | A value could be retrieved, but its type is not the one we expected (it was NOT an integer). Either the configuration file contains an invalid value, or no value has been defined in the configuration file and the $default value is invalid. |
Definition at line 378 of file Proxy.php.
References Erebot\Config\Proxy\parseSomething(), and Erebot\CallableWrapper\wrap().
|
static |
Parses a text and tries to extract an integer value.
| string | $value | The text from which an integer should be extracted. |
| int | If an integer could be extracted from the $value provided, it is returned as the corresponding PHP (signed) integer value. |
| null | If no integer could be extracted. |
| Erebot\Config\Proxy::parseReal | ( | $module, | |
| $param, | |||
$default = null |
|||
| ) |
Returns the real number for a setting in some module.
| string | $module | The name of the module from which to retrieved the setting. |
| string | $param | The name of the parameter we are interested in. |
| float | $default | (optional) A default value in case no value has been set at the configuration level. |
| float | The real number for that particular module and parameter. |
| Erebot::NotFoundException | The given $module or $param name could not be found. |
| Erebot::InvalidValueException | A value could be retrieved, but its type is not the one we expected (it was NOT a real). Either the configuration file contains an invalid value, or no value has been defined in the configuration file and the $default value is invalid. |
Definition at line 391 of file Proxy.php.
References Erebot\Config\Proxy\parseSomething(), and Erebot\CallableWrapper\wrap().
|
static |
Parses a text and tries to extract a real.
| string | $value | The text from which a real should be extracted. |
| float | If a real could be extracted from the $value provided, it is returned as the corresponding PHP float value. |
| null | If no real could be extracted. |
|
protected |
Returns the typed value for a module's parameter.
| string | $module | The name of the module. |
| string | $param | The name of the parameter to fetch from the module's settings. |
| mixed | $default | Default value if no value has been defined in the module's settings, or null if there is no default value. |
| Erebot::CallableInterface | $parser | Object that will be used to parse the parameter. It will receive the value of that parameter as a string and should convert it to the proper type. |
| string | $origin | Name of the method the request to parse the parameter originated from. |
| Erebot::CallableInterface | $checker | Object that will be passed the parsed value and should return true if it respects the type constraints defined by this checker, or false if it does not. |
| mixed | Value as parsed from the module's settings, or the default value if no value existed in the settings and it passed the type check. |
| Erebot::InvalidValueException | The value parsed or the default value did not pass the type check. |
| Erebot::NotFoundException |
Definition at line 313 of file Proxy.php.
Referenced by Erebot\Config\Proxy\parseBool(), Erebot\Config\Proxy\parseInt(), Erebot\Config\Proxy\parseReal(), and Erebot\Config\Proxy\parseString().
| Erebot\Config\Proxy::parseString | ( | $module, | |
| $param, | |||
$default = null |
|||
| ) |
Returns the string value for a setting in some module.
| string | $module | The name of the module from which to retrieved the setting. |
| string | $param | The name of the parameter we are interested in. |
| string | $default | (optional) A default value in case no value has been set at the configuration level. |
| string | The string value for that particular module and parameter. |
| Erebot::NotFoundException | The given $module or $param name could not be found. |
| Erebot::InvalidValueException | A value could be retrieved, but its type is not the one we expected (it was NOT a string). Either the configuration file contains an invalid value, or no value has been defined in the configuration file and the $default value is invalid. |
Definition at line 365 of file Proxy.php.
References Erebot\Config\Proxy\parseSomething(), and Erebot\CallableWrapper\wrap().