mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Optimizing Configure::delete(), you can now delete arbitrarily nested keys
This commit is contained in:
parent
eab2d8aa66
commit
81b41aa561
1 changed files with 6 additions and 6 deletions
|
@ -188,13 +188,13 @@ class Configure {
|
|||
* @return void
|
||||
*/
|
||||
public static function delete($var = null) {
|
||||
if (strpos($var, '.') === false) {
|
||||
unset(self::$_values[$var]);
|
||||
return;
|
||||
$keys = explode('.', $var);
|
||||
$last = array_pop($keys);
|
||||
$pointer = &self::$_values;
|
||||
foreach ($keys as $key) {
|
||||
$pointer = &$pointer[$key];
|
||||
}
|
||||
|
||||
$names = explode('.', $var, 2);
|
||||
self::$_values[$names[0]] = Set::remove(self::$_values[$names[0]], $names[1]);
|
||||
unset($pointer[$last]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue