Interface for a generic cascading configuration.
More...
Interface for a generic cascading configuration.
This interface provides methods which are common to different configuration interfaces.
Definition at line 30 of file Proxy.php.
| Erebot\Interfaces\Config\Proxy::getMainCfg |
( |
| ) |
|
Returns the root configuration associated with this hierarchy of configurations.
- Return values
-
| Erebot\Interfaces\Config\Proxy::getModule |
( |
|
$moduleName | ) |
|
Returns the instance of the module configuration with the given name.
- Parameters
-
| string | $moduleName | Name of the module whose configuration we're insterested in. |
- Return values
-
- Exceptions
-
| Erebot\Interfaces\Config\Proxy::getModules |
( |
|
$recursive | ) |
|
Returns a list with the names of all currently active modules.
- Parameters
-
| 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. |
- Return values
-
| list(string) | A list with the names of currently active modules. |
| Erebot\Interfaces\Config\Proxy::getTranslator |
( |
|
$component | ) |
|
Returns the appropriate i18n object to use for translations at this configuration level.
- Parameters
-
| 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. |
- Return values
-
- Exceptions
-
Implemented in Erebot\Config\Main.
| Erebot\Interfaces\Config\Proxy::parseBool |
( |
|
$module, |
|
|
|
$param, |
|
|
|
$default = null |
|
) |
| |
Returns the boolean value for a setting in some module.
- Parameters
-
| 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. |
- Return values
-
| bool | The boolean value for that particular module and parameter. |
- Exceptions
-
| 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. |
- Note
- This method tries to retrieve the value recursively by traversing the configuration hierarchy.
| Erebot\Interfaces\Config\Proxy::parseInt |
( |
|
$module, |
|
|
|
$param, |
|
|
|
$default = null |
|
) |
| |
Returns the integer value for a setting in some module.
- Parameters
-
| 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. |
- Return values
-
| int | The interger value for that particular module and parameter. |
- Exceptions
-
| 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. |
- Note
- The returned value is always signed. There is currently no way to restrict the range of allowed values using this function. If you need to apply restrictions, do it in the calling function:
$port = $config->parseInt('server', 'incomingPort');
if ($port <= 0 || $port > 65535)
throw new \\Erebot\\InvalidValueException(
"Incoming port value is out of range (1-65535)");
-
This method tries to retrieve the value recursively by traversing the configuration hierarchy.
| Erebot\Interfaces\Config\Proxy::parseReal |
( |
|
$module, |
|
|
|
$param, |
|
|
|
$default = null |
|
) |
| |
Returns the real number for a setting in some module.
- Parameters
-
| 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. |
- Return values
-
| float | The real number for that particular module and parameter. |
- Exceptions
-
| 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. |
- Note
- The returned value is not restricted in nay way. If you need to apply restrictions, do it in the calling function:
$price = $config->parseReal('prices', '$item);
if ($price <= 0.1)
throw \\Erebot\\InvalidValueException(
"Invalid price: we're losing money here!");
-
This method tries to retrieve the value recursively by traversing the configuration hierarchy.
| Erebot\Interfaces\Config\Proxy::parseString |
( |
|
$module, |
|
|
|
$param, |
|
|
|
$default = null |
|
) |
| |
Returns the string value for a setting in some module.
- Parameters
-
| 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. |
- Return values
-
| string | The string value for that particular module and parameter. |
- Exceptions
-
| 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. |
- Note
- This method tries to retrieve the value recursively by traversing the configuration hierarchy.
The documentation for this interface was generated from the following file:
- vendor/erebot/api/src/Interfaces/Config/Proxy.php