3.0 merge vars #901

merged 10 commits into from Oct 15, 2012


None yet

4 participants


Extract Object::_mergeVars() into a trait. This has a few benefits and lets us remove a pile of test classes as merging is much simpler now, and requires less code. I've written a wiki page with more information as well.

markstory added some commits Oct 9, 2012
@markstory markstory Extract mergeVars into a trait.
MergeVariablesTrait walks the entire inheritance tree.  This provides
a more consistent and predictable behavior in comparions to
Object::_mergeVars() which skips classes almost at random in the
inheritance tree.
@markstory markstory Fix merging properties that contain non-array values. 9b68da3
@markstory markstory Refactor _mergeVars()
- Extract boolean flags as a list of options instead.
- Add the ability to reverse merge properties.  This is primaryly useful
  for maintaining behavior in Controller::$uses.
@markstory markstory Update Controller to use MergeVariablesTrait
Remove a test case that handled the many edge cases with controller
merge vars as those cases should be covered by tests for the trait now.
@markstory markstory Update Shell to use MergeVariablesTrait. fb37e21
@markstory markstory Remove Object::_mergeVars.
Update Model mergeVars usage as well.
@markstory markstory Better remove Controller::$_mergeParent
I missed a few references last time, and the remaining ones were causing
@markstory markstory Fix issue with $uses merging.
* Fix missing model names when a controller did not define $uses.
* Remove un-necessary test classes.
@markstory markstory Remove un-used files.
* Update Plugin tests as there was an unused plugin.
@shama shama commented on an outdated diff Oct 14, 2012
+ $object = new Grandchild();
+ $object->mergeVars(['assocProperty', 'listProperty'], ['associative' => ['assocProperty']]);
+ $expected = [
+ 'Red' => null,
+ 'Orange' => null,
+ 'Green' => ['lime', 'apple'],
+ 'Yellow' => ['banana'],
+ ];
+ $this->assertEquals($expected, $object->assocProperty);
+ $expected = ['One', 'Two', 'Three', 'Four', 'Five'];
+ $this->assertSame($expected, $object->listProperty);
+ }
+ * Test that merging variables with booleans in the class heirarchy
shama Oct 14, 2012 Contributor


lorenzo commented Oct 14, 2012

Looks good to me, nice work!


Cool, I'll update the 3.0 docs and then merge this in.

jrbasso commented Oct 14, 2012


@markstory markstory merged commit 94131c6 into cakephp:3.0 Oct 15, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment