Erebot
latest
A modular IRC bot for PHP 7.0+
|
A configuration proxy which cascades settings. More...
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, callable $parser, $origin, callable $checker) | |
Static Protected Member Functions | |
static | getBaseDir ($component) |
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::parseBool | ( | $module, | |
$param, | |||
$default = null |
|||
) |
Definition at line 352 of file Proxy.php.
References Erebot\Config\Proxy\parseSomething().
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 |
|||
) |
Definition at line 378 of file Proxy.php.
References Erebot\Config\Proxy\parseSomething().
|
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 |
|||
) |
Definition at line 391 of file Proxy.php.
References Erebot\Config\Proxy\parseSomething().
|
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. |
callable | $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. |
callable | $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 |
|||
) |
Definition at line 365 of file Proxy.php.
References Erebot\Config\Proxy\parseSomething().