Changeset View
Changeset View
Standalone View
Standalone View
lib/Kolab/Config.php
Show First 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | class Config | ||||
public function register($config, $prefix = '') | public function register($config, $prefix = '') | ||||
{ | { | ||||
// merge the new config values over existing data | // merge the new config values over existing data | ||||
if (empty($prefix)) { | if (empty($prefix)) { | ||||
$this->data = array_replace_recursive($this->data, $config); | $this->data = array_replace_recursive($this->data, $config); | ||||
} | } | ||||
else if (is_array($config)) { | else if (is_array($config)) { | ||||
$pkey = rtrim($prefix, '.'); | $pkey = rtrim($prefix, '.'); | ||||
$this->data[$pkey] = is_array($this->data[$pkey]) ? array_replace_recursive((array)$this->data[$pkey], $config) : $config; | $this->data[$pkey] = isset($this->data[$pkey]) && is_array($this->data[$pkey]) | ||||
? array_replace_recursive((array)$this->data[$pkey], $config) | |||||
: $config; | |||||
} | } | ||||
foreach ((array)$config as $key => $val) { | foreach ((array)$config as $key => $val) { | ||||
if (is_array($val)) { | if (is_array($val)) { | ||||
$this->register($val, "$prefix$key."); | $this->register($val, "$prefix$key."); | ||||
} | } | ||||
else { | else { | ||||
$this->data[$prefix.$key] = $val; | $this->data[$prefix.$key] = $val; | ||||
Show All 24 Lines | protected function replace_reference($m) | ||||
return $this->data[$m[1]]; | return $this->data[$m[1]]; | ||||
} | } | ||||
/** | /** | ||||
* Magic getter for direct read-only access to config options | * Magic getter for direct read-only access to config options | ||||
*/ | */ | ||||
public function __get($name) | public function __get($name) | ||||
{ | { | ||||
return $this->data[$name]; | return isset($this->data[$name]) ? $this->data[$name] : null; | ||||
} | } | ||||
/** | /** | ||||
* Magic isset check | * Magic isset check | ||||
*/ | */ | ||||
public function __isset($name) | public function __isset($name) | ||||
{ | { | ||||
return array_key_exists($name, $this->data); | return array_key_exists($name, $this->data); | ||||
▲ Show 20 Lines • Show All 151 Lines • Show Last 20 Lines |