Skip to content
Permalink
Browse files

Remove Object::_mergeVars.

Update Model mergeVars usage as well.
  • Loading branch information...
markstory committed Oct 13, 2012
1 parent fb37e21 commit 6cc0046fd838945afa45edf4bd33c9ee86f05a94
Showing with 8 additions and 41 deletions.
  1. +0 −30 lib/Cake/Core/Object.php
  2. +8 −11 lib/Cake/Model/Model.php
@@ -174,34 +174,4 @@ protected function _set($properties = array()) {
}
}
/**
* Merges this objects $property with the property in $class' definition.
* This classes value for the property will be merged on top of $class'
*
* This provides some of the DRY magic CakePHP provides. If you want to shut it off, redefine
* this method as an empty function.
*
* @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 Hash::normalize() before merging.
* @return void
*/
protected function _mergeVars($properties, $class, $normalize = true) {
$classProperties = get_class_vars($class);
foreach ($properties as $var) {
if (
isset($classProperties[$var]) &&
!empty($classProperties[$var]) &&
is_array($this->{$var}) &&
$this->{$var} != $classProperties[$var]
) {
if ($normalize) {
$classProperties[$var] = Hash::normalize($classProperties[$var]);
$this->{$var} = Hash::normalize($this->{$var});
}
$this->{$var} = Hash::merge($classProperties[$var], $this->{$var});
}
}
}
}
@@ -18,8 +18,8 @@
* @since CakePHP(tm) v 0.10.0.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace Cake\Model;
use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Core\Object;
@@ -30,6 +30,7 @@
use Cake\Utility\ClassRegistry;
use Cake\Utility\Hash;
use Cake\Utility\Inflector;
use Cake\Utility\MergeVariablesTrait;
use Cake\Utility\Set;
use Cake\Utility\Xml;
@@ -46,6 +47,8 @@
*/
class Model extends Object implements EventListener {
use MergeVariablesTrait;
/**
* The name of the DataSource connection that this Model uses
*
@@ -714,16 +717,10 @@ public function __construct($id = false, $table = null, $ds = null) {
$this->useDbConfig = $ds;
}
$appModelClass = App::classname('Model', 'Model');
if (is_subclass_of($this, $appModelClass)) {
$merge = array('actsAs', 'findMethods');
$parentClass = get_parent_class($this);
if ($parentClass !== $appModelClass) {
$this->_mergeVars($merge, $parentClass);
}
$this->_mergeVars($merge, $appModelClass);
}
$this->_mergeVars(array('findMethods'), 'Model');
$this->_mergeVars(
['actsAs', 'findMethods'],
['associative' => ['actsAs', 'findMethods']]
);
$this->Behaviors = new BehaviorCollection();

0 comments on commit 6cc0046

Please sign in to comment.
You can’t perform that action at this time.