mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #9667 from bancer/components-enabled-setting
fixed configuration of 'enabled' setting in components inside a
This commit is contained in:
commit
7f0b0739a8
2 changed files with 18 additions and 2 deletions
|
@ -90,7 +90,7 @@ class Component extends CakeObject {
|
|||
*/
|
||||
public function __get($name) {
|
||||
if (isset($this->_componentMap[$name]) && !isset($this->{$name})) {
|
||||
$settings = array('enabled' => false) + (array)$this->_componentMap[$name]['settings'];
|
||||
$settings = (array)$this->_componentMap[$name]['settings'] + array('enabled' => false);
|
||||
$this->{$name} = $this->_Collection->load($this->_componentMap[$name]['class'], $settings);
|
||||
}
|
||||
if (isset($this->{$name})) {
|
||||
|
|
|
@ -31,7 +31,10 @@ class ParamTestComponent extends Component {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public $components = array('Banana' => array('config' => 'value'));
|
||||
public $components = array(
|
||||
'Apple' => array('enabled' => true),
|
||||
'Banana' => array('config' => 'value'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -286,4 +289,17 @@ class ComponentTest extends CakeTestCase {
|
|||
$this->assertInstanceOf('EmailComponent', $Controller->SomethingWithEmail->Email);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test lazy loading of components inside components and both explicit and
|
||||
* implicit 'enabled' setting.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGet() {
|
||||
$Collection = new ComponentCollection();
|
||||
$ParamTest = $Collection->load('ParamTest');
|
||||
$this->assertTrue($ParamTest->Apple->settings['enabled']);
|
||||
$this->assertFalse($ParamTest->Banana->settings['enabled']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue