Update to use Hash.

Update CakeSession & Configure to use Hash.
This commit is contained in:
mark_story 2012-03-07 23:26:40 -05:00
parent 8becc4c985
commit 29048b3bb7
2 changed files with 11 additions and 31 deletions

View file

@ -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]);
}
}
}

View file

@ -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;
}
}