60 \SimpleXMLElement $xml
63 $this->modules = array();
65 if (isset($xml[
'language'])) {
66 $this->locale = (string) $xml[
'language'];
71 if (!isset($xml->modules->module)) {
75 foreach ($xml->modules->module as $module) {
77 $instance = new \Erebot\Config\Module($module);
78 $this->modules[$instance->getName()] = $instance;
99 throw new \Exception(
"Cloning forbidden!");
105 if (isset($this->locale)) {
106 $translator = new \Erebot\Intl($component);
107 $translator->setLocale(
116 $proxiedTranslator = $this->proxified->getTranslator($component);
117 foreach ($categories as $category) {
118 $translator->setLocale(
120 $proxiedTranslator->getLocale($category)
125 if ($this->proxified === $this) {
126 throw new \Erebot\NotFoundException(
'No translator associated');
128 return $this->proxified->getTranslator($component);
134 if ($this->proxified === $this) {
137 return $this->proxified->getMainCfg();
143 if (!is_bool($recursive)) {
144 throw new \Erebot\InvalidValueException(
145 'Invalid value for recursion' 149 if ($recursive && $this->proxified !== $this) {
150 $inherited = $this->proxified->getModules(
true);
152 $inherited = array();
157 foreach ($this->modules as $name => $module) {
158 if ($module->isActive()) {
165 $inherited = array_diff($inherited, $removed);
166 return array_merge($added, $inherited);
172 $moduleName =
'\\' . ltrim($moduleName,
'\\');
173 if (!isset($this->modules[$moduleName])) {
174 if ($this->proxified !== $this) {
175 return $this->proxified->getModule($moduleName);
177 throw new \Erebot\NotFoundException(
'No such module "' .
180 return $this->modules[$moduleName];
205 $value = strtolower($value);
206 if (in_array($value, array(
'true',
'1',
'on',
'yes'),
true)) {
209 if (in_array($value, array(
'false',
'0',
'off',
'no'),
true)) {
234 if (is_int($value)) {
238 if (ctype_digit($value)) {
242 if (strpos(
'+-', $value[0]) !==
false && ctype_digit(substr($value, 1))) {
264 if (!is_numeric($value)) {
268 return (
double) $value;
322 if (!isset($this->modules[$module])) {
323 throw new \Erebot\NotFoundException(
'No such module');
325 $value = $this->modules[$module]->getParam($param);
326 $value = $parser($value);
327 if ($value !== null) {
330 throw new \Erebot\InvalidValueException(
331 'Bad value in configuration' 334 if ($this->proxified !== $this) {
335 return $this->proxified->$origin($module, $param, $default);
338 if ($default === null) {
339 throw new \Erebot\NotFoundException(
'No such parameter "' .
340 $param .
'" for module "' .
344 if ($checker($default)) {
347 throw new \Erebot\InvalidValueException(
'Bad default value');
352 public function parseBool($module, $param, $default = null)
378 public function parseInt($module, $param, $default = null)
391 public function parseReal($module, $param, $default = null)
parseReal($module, $param, $default=null)
$locale
The current locale.
Interface for something that can be called.
parseBool($module, $param, $default=null)
static parseBoolHelper($value)
getTranslator($component)
const LC_NUMERIC
Non-monetary numeric formats.
__construct(\Erebot\Interfaces\Config\Proxy $proxified,\SimpleXMLElement $xml)
static parseRealHelper($value)
$proxified
Reference to a proxified object.
parseInt($module, $param, $default=null)
An exception thrown when the given item could not be found.
const LC_MONETARY
Monetary formats.
parseString($module, $param, $default=null)
static parseIntHelper($value)
A configuration proxy which cascades settings.
const LC_TIME
Date and time formats.
$modules
Array of modules loaded at this particular configuration level.
parseSomething($module, $param, $default,\Erebot\CallableInterface $parser, $origin,\Erebot\CallableInterface $checker)