mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Optimizing and simplifying Configure::write(), this also allows arbitrary nesting limit in configure keys
This commit is contained in:
parent
2c5cb1157f
commit
3a48f64370
1 changed files with 5 additions and 19 deletions
|
@ -124,26 +124,12 @@ class Configure {
|
|||
}
|
||||
|
||||
foreach ($config as $name => $value) {
|
||||
if (strpos($name, '.') === false) {
|
||||
self::$_values[$name] = $value;
|
||||
} else {
|
||||
$names = explode('.', $name, 4);
|
||||
switch (count($names)) {
|
||||
case 2:
|
||||
self::$_values[$names[0]][$names[1]] = $value;
|
||||
break;
|
||||
case 3:
|
||||
self::$_values[$names[0]][$names[1]][$names[2]] = $value;
|
||||
break;
|
||||
case 4:
|
||||
$names = explode('.', $name, 2);
|
||||
if (!isset(self::$_values[$names[0]])) {
|
||||
self::$_values[$names[0]] = array();
|
||||
}
|
||||
self::$_values[$names[0]] = Set::insert(self::$_values[$names[0]], $names[1], $value);
|
||||
break;
|
||||
}
|
||||
$pointer = &self::$_values;
|
||||
foreach (explode('.', $name) as $key) {
|
||||
$pointer = &$pointer[$key];
|
||||
}
|
||||
$pointer = $value;
|
||||
unset($pointer);
|
||||
}
|
||||
|
||||
if (isset($config['debug']) && function_exists('ini_set')) {
|
||||
|
|
Loading…
Reference in a new issue