Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Optimizing Configure::delete(), you can now delete arbitrarily nested…

… keys
  • Loading branch information...
commit 81b41aa561d8aa0ccf58ed1a130bcb575d72bb6a 1 parent eab2d8a
@lorenzo lorenzo authored
Showing with 6 additions and 6 deletions.
  1. +6 −6 lib/Cake/Core/Configure.php
View
12 lib/Cake/Core/Configure.php
@@ -188,13 +188,13 @@ public static function read($var = null) {
* @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]);
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.