From 29048b3bb775605b51338eabafa2bf990359acea Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 7 Mar 2012 23:26:40 -0500 Subject: [PATCH] Update to use Hash. Update CakeSession & Configure to use Hash. --- lib/Cake/Core/Configure.php | 30 ++++------------------- lib/Cake/Model/Datasource/CakeSession.php | 12 ++++----- 2 files changed, 11 insertions(+), 31 deletions(-) diff --git a/lib/Cake/Core/Configure.php b/lib/Cake/Core/Configure.php index 887b2b1e1..2d97bcfd9 100644 --- a/lib/Cake/Core/Configure.php +++ b/lib/Cake/Core/Configure.php @@ -13,7 +13,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('Set', 'Utility'); +App::uses('Hash', 'Utility'); App::uses('ConfigReaderInterface', 'Configure'); /** @@ -127,12 +127,7 @@ class Configure { } foreach ($config as $name => $value) { - $pointer = &self::$_values; - foreach (explode('.', $name) as $key) { - $pointer = &$pointer[$key]; - } - $pointer = $value; - unset($pointer); + self::$_values = Hash::insert(self::$_values, $name, $value); } if (isset($config['debug']) && function_exists('ini_set')) { @@ -163,18 +158,7 @@ class Configure { if ($var === null) { return self::$_values; } - if (isset(self::$_values[$var])) { - return self::$_values[$var]; - } - $pointer = &self::$_values; - foreach (explode('.', $var) as $key) { - if (isset($pointer[$key])) { - $pointer = &$pointer[$key]; - } else { - return null; - } - } - return $pointer; + return Hash::get(self::$_values, $var); } /** @@ -193,11 +177,7 @@ class Configure { public static function delete($var = null) { $keys = explode('.', $var); $last = array_pop($keys); - $pointer = &self::$_values; - foreach ($keys as $key) { - $pointer = &$pointer[$key]; - } - unset($pointer[$last]); + self::$_values = Hash::remove(self::$_values, $var); } /** @@ -286,7 +266,7 @@ class Configure { $keys = array_keys($values); foreach ($keys as $key) { if (($c = self::read($key)) && is_array($values[$key]) && is_array($c)) { - $values[$key] = Set::merge($c, $values[$key]); + $values[$key] = Hash::merge($c, $values[$key]); } } } diff --git a/lib/Cake/Model/Datasource/CakeSession.php b/lib/Cake/Model/Datasource/CakeSession.php index b631b3c1c..2c15b9cbe 100644 --- a/lib/Cake/Model/Datasource/CakeSession.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -22,7 +22,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('Set', 'Utility'); +App::uses('Hash', 'Utility'); App::uses('Security', 'Utility'); /** @@ -216,7 +216,7 @@ class CakeSession { if (empty($name)) { return false; } - $result = Set::classicExtract($_SESSION, $name); + $result = Hash::get($_SESSION, $name); return isset($result); } @@ -364,9 +364,9 @@ class CakeSession { if (empty($name)) { return false; } - $result = Set::classicExtract($_SESSION, $name); + $result = Hash::get($_SESSION, $name); - if (!is_null($result)) { + if (isset($result)) { return $result; } self::_setError(2, "$name doesn't exist"); @@ -405,8 +405,8 @@ class CakeSession { $write = array($name => $value); } foreach ($write as $key => $val) { - self::_overwrite($_SESSION, Set::insert($_SESSION, $key, $val)); - if (Set::classicExtract($_SESSION, $key) !== $val) { + self::_overwrite($_SESSION, Hash::insert($_SESSION, $key, $val)); + if (Hash::get($_SESSION, $key) !== $val) { return false; } }