Permalink
Browse files

Switch usage to Hash where possible.

  • Loading branch information...
1 parent 29048b3 commit 19e0d8d946eaa544652fd46a04b872c9637c1634 @markstory markstory committed Mar 11, 2012
Showing with 148 additions and 141 deletions.
  1. +1 −1 lib/Cake/Configure/IniReader.php
  2. +3 −1 lib/Cake/Console/Command/AclShell.php
  3. +1 −1 lib/Cake/Console/Command/ConsoleShell.php
  4. +2 −1 lib/Cake/Console/Command/Task/ExtractTask.php
  5. +1 −0 lib/Cake/Controller/Component/Acl/DbAcl.php
  6. +2 −2 lib/Cake/Controller/Component/Acl/IniAcl.php
  7. +1 −1 lib/Cake/Controller/Component/Acl/PhpAcl.php
  8. +2 −2 lib/Cake/Controller/Component/Auth/BaseAuthenticate.php
  9. +2 −1 lib/Cake/Controller/Component/Auth/BaseAuthorize.php
  10. +3 −3 lib/Cake/Controller/Component/AuthComponent.php
  11. +4 −3 lib/Cake/Controller/Component/CookieComponent.php
  12. +2 −1 lib/Cake/Controller/Component/PaginatorComponent.php
  13. +2 −1 lib/Cake/Controller/Component/SecurityComponent.php
  14. +4 −4 lib/Cake/Core/Object.php
  15. +2 −1 lib/Cake/Model/Behavior/AclBehavior.php
  16. +1 −1 lib/Cake/Model/Behavior/ContainableBehavior.php
  17. +3 −3 lib/Cake/Model/Behavior/TreeBehavior.php
  18. +2 −2 lib/Cake/Model/Datasource/CakeSession.php
  19. +1 −1 lib/Cake/Model/Datasource/Database/Postgres.php
  20. +4 −4 lib/Cake/Model/Datasource/DboSource.php
  21. +8 −8 lib/Cake/Model/Model.php
  22. +5 −5 lib/Cake/Network/CakeRequest.php
  23. +1 −1 lib/Cake/Network/Email/CakeEmail.php
  24. +8 −8 lib/Cake/Network/Http/HttpSocket.php
  25. +1 −1 lib/Cake/Routing/Route/CakeRoute.php
  26. +2 −2 lib/Cake/Routing/Router.php
  27. +1 −1 lib/Cake/Test/Case/Console/ShellTest.php
  28. +19 −19 lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php
  29. +3 −3 lib/Cake/Test/Case/Controller/ControllerTest.php
  30. +13 −15 lib/Cake/Test/Case/Model/AclNodeTest.php
  31. +2 −2 lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php
  32. +6 −6 lib/Cake/Test/Case/Model/BehaviorCollectionTest.php
  33. +9 −9 lib/Cake/Test/Case/Model/ModelReadTest.php
  34. +10 −10 lib/Cake/Test/Case/Model/ModelWriteTest.php
  35. +2 −2 lib/Cake/Test/Case/Network/Http/HttpSocketTest.php
  36. +1 −1 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
  37. +1 −1 lib/Cake/Utility/Debugger.php
  38. +5 −5 lib/Cake/Utility/Hash.php
  39. +2 −2 lib/Cake/View/Helper.php
  40. +3 −3 lib/Cake/View/Helper/FormHelper.php
  41. +1 −1 lib/Cake/View/Helper/NumberHelper.php
  42. +1 −1 lib/Cake/View/Helper/TextHelper.php
  43. +1 −1 lib/Cake/View/Helper/TimeHelper.php
@@ -127,7 +127,7 @@ protected function _parseNestedValues($values) {
$value = false;
}
if (strpos($key, '.') !== false) {
- $values = Set::insert($values, $key, $value);
+ $values = Hash::insert($values, $key, $value);
} else {
$values[$key] = $value;
}
@@ -21,6 +21,7 @@
App::uses('ComponentCollection', 'Controller');
App::uses('AclComponent', 'Controller/Component');
App::uses('DbAcl', 'Model');
+App::uses('Hash', 'Utility');
/**
* Shell for ACL management. This console is known to have issues with zend.ze1_compatibility_mode
@@ -558,8 +559,9 @@ protected function _getNodeId($class, $identifier) {
$identifier = var_export($identifier, true);
}
$this->error(__d('cake_console', 'Could not find node using reference "%s"', $identifier));
+ return;
}
- return Set::extract($node, "0.{$class}.id");
+ return Hash::get($node, "0.{$class}.id");
}
/**
@@ -300,7 +300,7 @@ public function main($command = null) {
break;
case (preg_match("/^routes\s+show/i", $command, $tmp) == true):
$router = Router::getInstance();
- $this->out(implode("\n", Set::extract($router->routes, '{n}.0')));
+ $this->out(implode("\n", Hash::extract($router->routes, '{n}.0')));
break;
case (preg_match("/^route\s+(\(.*\))$/i", $command, $tmp) == true):
if ($url = eval('return array' . $tmp[1] . ';')) {
@@ -19,6 +19,7 @@
App::uses('AppShell', 'Console/Command');
App::uses('File', 'Utility');
App::uses('Folder', 'Utility');
+App::uses('Hash', 'Utility');
/**
* Language string extractor
@@ -431,7 +432,7 @@ protected function _processValidationRules($field, $rules, $file, $domain) {
return;
}
- $dims = Set::countDim($rules);
+ $dims = Hash::dimensions($rules);
if ($dims == 1 || ($dims == 2 && isset($rules['message']))) {
$rules = array($rules);
}
@@ -13,6 +13,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AclInterface', 'Controller/Component/Acl');
+App::uses('Hash', 'Utility');
/**
* DbAcl implements an ACL control system in the database. ARO's and ACO's are
@@ -30,7 +30,7 @@ class IniAcl extends Object implements AclInterface {
public $config = null;
/**
- * The Set::classicExtract() path to the user/aro identifier in the
+ * The Hash::extract() path to the user/aro identifier in the
* acl.ini file. This path will be used to extract the string
* representation of a user used in the ini file.
*
@@ -97,7 +97,7 @@ public function check($aro, $aco, $action = null) {
$aclConfig = $this->config;
if (is_array($aro)) {
- $aro = Set::classicExtract($aro, $this->userPath);
+ $aro = Hash::get($aro, $this->userPath);
}
if (isset($aclConfig[$aro]['deny'])) {
@@ -494,7 +494,7 @@ public function addRole(array $aro) {
// detect cycles
$roles = $this->roles($dependency);
- if (in_array($role, Set::flatten($roles))) {
+ if (in_array($role, Hash::flatten($roles))) {
$path = '';
foreach ($roles as $roleDependencies) {
@@ -12,8 +12,8 @@
* @link http://cakephp.org CakePHP(tm) Project
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-
App::uses('Security', 'Utility');
+App::uses('Hash', 'Utility');
/**
* Base Authentication class with common methods and properties.
@@ -58,7 +58,7 @@
*/
public function __construct(ComponentCollection $collection, $settings) {
$this->_Collection = $collection;
- $this->settings = Set::merge($this->settings, $settings);
+ $this->settings = Hash::merge($this->settings, $settings);
}
/**
@@ -12,6 +12,7 @@
* @link http://cakephp.org CakePHP(tm) Project
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
+App::uses('Hash', 'Utility');
/**
* Abstract base authorization adapter for AuthComponent.
@@ -69,7 +70,7 @@ public function __construct(ComponentCollection $collection, $settings = array()
$this->_Collection = $collection;
$controller = $collection->getController();
$this->controller($controller);
- $this->settings = Set::merge($this->settings, $settings);
+ $this->settings = Hash::merge($this->settings, $settings);
}
/**
@@ -19,11 +19,11 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-
App::uses('Component', 'Controller');
App::uses('Router', 'Routing');
App::uses('Security', 'Utility');
App::uses('Debugger', 'Utility');
+App::uses('Hash', 'Utility');
App::uses('CakeSession', 'Model/Datasource');
App::uses('BaseAuthorize', 'Controller/Component/Auth');
App::uses('BaseAuthenticate', 'Controller/Component/Auth');
@@ -394,7 +394,7 @@ public function constructAuthorize() {
return;
}
$this->_authorizeObjects = array();
- $config = Set::normalize($this->authorize);
+ $config = Hash::normalize((array)$this->authorize);
$global = array();
if (isset($config[AuthComponent::ALL])) {
$global = $config[AuthComponent::ALL];
@@ -652,7 +652,7 @@ public function constructAuthenticate() {
return;
}
$this->_authenticateObjects = array();
- $config = Set::normalize($this->authenticate);
+ $config = Hash::normalize((array)$this->authenticate);
$global = array();
if (isset($config[AuthComponent::ALL])) {
$global = $config[AuthComponent::ALL];
@@ -19,6 +19,7 @@
App::uses('Component', 'Controller');
App::uses('Security', 'Utility');
+App::uses('Hash', 'Utility');
/**
* Cookie Component.
@@ -239,7 +240,7 @@ public function write($key, $value = null, $encrypt = true, $expires = null) {
if (!isset($this->_values[$this->name][$names[0]])) {
$this->_values[$this->name][$names[0]] = array();
}
- $this->_values[$this->name][$names[0]] = Set::insert($this->_values[$this->name][$names[0]], $names[1], $value);
+ $this->_values[$this->name][$names[0]] = Hash::insert($this->_values[$this->name][$names[0]], $names[1], $value);
$this->_write('[' . implode('][', $names) . ']', $value);
}
}
@@ -276,7 +277,7 @@ public function read($key = null) {
}
if (!empty($names[1])) {
- return Set::extract($this->_values[$this->name][$key], $names[1]);
+ return Hash::get($this->_values[$this->name][$key], $names[1]);
}
return $this->_values[$this->name][$key];
}
@@ -310,7 +311,7 @@ public function delete($key) {
}
$names = explode('.', $key, 2);
if (isset($this->_values[$this->name][$names[0]])) {
- $this->_values[$this->name][$names[0]] = Set::remove($this->_values[$this->name][$names[0]], $names[1]);
+ $this->_values[$this->name][$names[0]] = Hash::remove($this->_values[$this->name][$names[0]], $names[1]);
}
$this->_delete('[' . implode('][', $names) . ']');
}
@@ -16,6 +16,7 @@
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
+App::uses('Hash', 'Utility');
/**
* This component is used to handle automatic model data pagination. The primary way to use this
@@ -194,7 +195,7 @@ public function paginate($object = null, $scope = array(), $whitelist = array())
'pageCount' => $pageCount,
'order' => $order,
'limit' => $limit,
- 'options' => Set::diff($options, $defaults),
+ 'options' => Hash::diff($options, $defaults),
'paramType' => $options['paramType']
);
if (!isset($this->Controller->request['paging'])) {
@@ -19,6 +19,7 @@
App::uses('Component', 'Controller');
App::uses('String', 'Utility');
+App::uses('Hash', 'Utility');
App::uses('Security', 'Utility');
/**
@@ -443,7 +444,7 @@ protected function _validatePost(Controller $controller) {
$unlocked = explode('|', $unlocked);
$lockedFields = array();
- $fields = Set::flatten($check);
+ $fields = Hash::flatten($check);
$fieldList = array_keys($fields);
$multi = array();
@@ -181,7 +181,7 @@ protected function _set($properties = array()) {
*
* @param array $properties The name of the properties to merge.
* @param string $class The class to merge the property with.
- * @param boolean $normalize Set to true to run the properties through Set::normalize() before merging.
+ * @param boolean $normalize Set to true to run the properties through Hash::normalize() before merging.
* @return void
*/
protected function _mergeVars($properties, $class, $normalize = true) {
@@ -194,10 +194,10 @@ protected function _mergeVars($properties, $class, $normalize = true) {
$this->{$var} != $classProperties[$var]
) {
if ($normalize) {
- $classProperties[$var] = Set::normalize($classProperties[$var]);
- $this->{$var} = Set::normalize($this->{$var});
+ $classProperties[$var] = Hash::normalize($classProperties[$var]);
+ $this->{$var} = Hash::normalize($this->{$var});
}
- $this->{$var} = Set::merge($classProperties[$var], $this->{$var});
+ $this->{$var} = Hash::merge($classProperties[$var], $this->{$var});
}
}
}
@@ -19,6 +19,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AclNode', 'Model');
+App::uses('Hash', 'Utility');
/**
* ACL behavior
@@ -131,7 +132,7 @@ public function afterDelete(Model $model) {
$types = array($types);
}
foreach ($types as $type) {
- $node = Set::extract($this->node($model, null, $type), "0.{$type}.id");
+ $node = Hash::extract($this->node($model, null, $type), "0.{$type}.id");
if (!empty($node)) {
$model->{$type}->delete($node);
}
@@ -321,7 +321,7 @@ public function containments(Model $Model, $contain, $containments = array(), $t
$key = $option;
$optionKey = true;
if (!empty($newChildren)) {
- $children = Set::merge($children, $newChildren);
+ $children = Hash::merge($children, $newChildren);
}
}
if ($optionKey && isset($children[$key])) {
@@ -363,10 +363,10 @@ public function generateTreeList(Model $Model, $conditions = null, $keyPath = nu
}
if ($valuePath == null) {
- $valuePath = array('{0}{1}', '{n}.tree_prefix', '{n}.' . $Model->alias . '.' . $Model->displayField);
+ $valuePath = array('%s%s', '{n}.tree_prefix', '{n}.' . $Model->alias . '.' . $Model->displayField);
} elseif (is_string($valuePath)) {
- $valuePath = array('{0}{1}', '{n}.tree_prefix', $valuePath);
+ $valuePath = array('%s%s', '{n}.tree_prefix', $valuePath);
} else {
$valuePath[0] = '{' . (count($valuePath) - 1) . '}' . $valuePath[0];
@@ -386,7 +386,7 @@ public function generateTreeList(Model $Model, $conditions = null, $keyPath = nu
if (empty($results)) {
return array();
}
- return Set::combine($results, $keyPath, $valuePath);
+ return Hash::combine($results, $keyPath, $valuePath);
}
/**
@@ -245,7 +245,7 @@ public static function id($id = null) {
*/
public static function delete($name) {
if (self::check($name)) {
- self::_overwrite($_SESSION, Set::remove($_SESSION, $name));
+ self::_overwrite($_SESSION, Hash::remove($_SESSION, $name));
return (self::check($name) == false);
}
self::_setError(2, __d('cake_dev', "%s doesn't exist", $name));
@@ -452,7 +452,7 @@ protected static function _configureSession() {
if (isset($sessionConfig['defaults'])) {
$defaults = self::_defaultConfig($sessionConfig['defaults']);
if ($defaults) {
- $sessionConfig = Set::merge($defaults, $sessionConfig);
+ $sessionConfig = Hash::merge($defaults, $sessionConfig);
}
}
if (!isset($sessionConfig['ini']['session.cookie_secure']) && env('HTTPS')) {
@@ -421,7 +421,7 @@ protected function _quoteFunctionField($match) {
$match[1] = $this->name($match[1]);
} elseif (!$constant) {
$parts = explode('.', $match[1]);
- if (!Set::numeric($parts)) {
+ if (!Hash::numeric($parts)) {
$match[1] = $this->name($match[1]);
}
}
@@ -1409,7 +1409,7 @@ protected function _mergeAssociation(&$data, &$merge, $association, $type, $self
if ($mergeKeys[0] === $dataKeys[0] || $mergeKeys === $dataKeys) {
$data[$association][$association] = $merge[0][$association];
} else {
- $diff = Set::diff($dataAssocTmp, $mergeAssocTmp);
+ $diff = Hash::diff($dataAssocTmp, $mergeAssocTmp);
$data[$association] = array_merge($merge[0][$association], $diff);
}
} elseif ($selfJoin && array_key_exists($association, $merge[0])) {
@@ -1934,7 +1934,7 @@ protected function _matchRecords(Model $model, $conditions = null) {
return false;
}
$conditions = $this->conditions(array(
- $model->primaryKey => Set::extract($idList, "{n}.{$model->alias}.{$model->primaryKey}")
+ $model->primaryKey => Hash::extract($idList, "{n}.{$model->alias}.{$model->primaryKey}")
));
}
return $conditions;
@@ -2256,7 +2256,7 @@ public function fields(Model $model, $alias = null, $fields = array(), $quote =
} else {
if (strpos($fields[$i], ',') === false) {
$build = explode('.', $fields[$i]);
- if (!Set::numeric($build)) {
+ if (!Hash::numeric($build)) {
$fields[$i] = $this->name(implode('.', $build));
}
}
@@ -2268,7 +2268,7 @@ public function fields(Model $model, $alias = null, $fields = array(), $quote =
$field[1] = $this->name($alias . '.' . $field[1]);
} else {
$field[0] = explode('.', $field[1]);
- if (!Set::numeric($field[0])) {
+ if (!Hash::numeric($field[0])) {
$field[0] = implode('.', array_map(array(&$this, 'name'), $field[0]));
$fields[$i] = preg_replace('/\(' . $field[1] . '\)/', '(' . $field[0] . ')', $fields[$i], 1);
}
Oops, something went wrong. Retry.

0 comments on commit 19e0d8d

Please sign in to comment.