3.0 merge vars #901

Merged
merged 10 commits into from Oct 15, 2012

Projects

None yet

4 participants

@markstory
Member

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.
35641cd
@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.
933a7e6
@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.
f108089
@markstory markstory Update Shell to use MergeVariablesTrait. fb37e21
@markstory markstory Remove Object::_mergeVars.
Update Model mergeVars usage as well.
6cc0046
@markstory markstory Better remove Controller::$_mergeParent
I missed a few references last time, and the remaining ones were causing
problems.
ec17c0c
@markstory markstory Fix issue with $uses merging.
* Fix missing model names when a controller did not define $uses.
* Remove un-necessary test classes.
7fe7ce7
@markstory markstory Remove un-used files.
* Update Plugin tests as there was an unused plugin.
471709a
@shama shama commented on an outdated diff Oct 14, 2012
...ake/Test/TestCase/Utility/MergeVariablesTraitTest.php
+ $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
shama Oct 14, 2012 Contributor

/heirarchy/hierarchy/

@lorenzo
Member
lorenzo commented Oct 14, 2012

Looks good to me, nice work!

@markstory
Member

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

@jrbasso
Member
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