mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
fixes #4858, self referencing components
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7133 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
52d72a63b5
commit
1c21457eef
2 changed files with 82 additions and 42 deletions
|
@ -216,8 +216,8 @@ class Component extends Object {
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($object->{$component}->components) && is_array($object->{$component}->components)) {
|
||||
$this->_loadComponents($object->{$component});
|
||||
if (isset($object->{$component}->components) && is_array($object->{$component}->components) && (!isset($object->{$component}->{$parent}))) {
|
||||
$this->_loadComponents($object->{$component}, $component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -207,6 +207,30 @@ class BananaComponent extends Object {
|
|||
var $testField = 'BananaField';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* MutuallyReferencingOneComponent class
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.controller
|
||||
*/
|
||||
class MutuallyReferencingOneComponent extends Object {
|
||||
var $components = array('MutuallyReferencingTwo');
|
||||
}
|
||||
|
||||
/**
|
||||
* MutuallyReferencingTwoComponent class
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.controller
|
||||
*/
|
||||
class MutuallyReferencingTwoComponent extends Object {
|
||||
var $components = array('MutuallyReferencingOne');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* ComponentTest class
|
||||
*
|
||||
|
@ -348,5 +372,21 @@ class ComponentTest extends CakeTestCase {
|
|||
$this->assertEqual($Controller->Orange->settings, array('colour' => 'blood orange', 'ripeness' => 'perfect'));
|
||||
$this->assertEqual($Controller->ParamTest->test, 'value');
|
||||
}
|
||||
/**
|
||||
* Test mutually referencing components.
|
||||
*
|
||||
*
|
||||
*/
|
||||
function testMutuallyReferencingComponents() {
|
||||
$Controller =& new ComponentTestController();
|
||||
$Controller->components = array('MutuallyReferencingOne');
|
||||
$Controller->constructClasses();
|
||||
$Controller->Component->initialize($Controller);
|
||||
|
||||
$this->assertTrue(is_a($Controller->MutuallyReferencingOne, 'MutuallyReferencingOneComponent'));
|
||||
$this->assertTrue(is_a($Controller->MutuallyReferencingOne->MutuallyReferencingTwo, 'MutuallyReferencingTwoComponent'));
|
||||
$this->assertTrue(is_a($Controller->MutuallyReferencingOne->MutuallyReferencingTwo->MutuallyReferencingOne, 'MutuallyReferencingOneComponent'));
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue