mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
updating code from [8024] [8025]
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8031 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
a3f4c60139
commit
43ad3d76e5
3 changed files with 52 additions and 55 deletions
|
@ -177,41 +177,27 @@ class Component extends Object {
|
|||
*/
|
||||
function _loadComponents(&$object, $parent = null) {
|
||||
$base = $this->__controllerVars['base'];
|
||||
$normal = Set::normalize($object->components);
|
||||
if ($parent == null) {
|
||||
$normal = Set::merge(array('Session' => null), $normal);
|
||||
}
|
||||
foreach ((array)$normal as $component => $config) {
|
||||
$plugin = null;
|
||||
|
||||
if (is_array($object->components)) {
|
||||
$normal = Set::normalize($object->components);
|
||||
if ($parent == null) {
|
||||
$normal['Session'] = array();
|
||||
if (isset($this->__controllerVars['plugin'])) {
|
||||
$plugin = $this->__controllerVars['plugin'] . '.';
|
||||
}
|
||||
foreach ($normal as $component => $config) {
|
||||
$plugin = null;
|
||||
|
||||
if (isset($this->__controllerVars['plugin'])) {
|
||||
$plugin = $this->__controllerVars['plugin'] . '.';
|
||||
}
|
||||
if (strpos($component, '.') !== false) {
|
||||
list($plugin, $component) = explode('.', $component);
|
||||
$plugin = $plugin . '.';
|
||||
}
|
||||
$componentCn = $component . 'Component';
|
||||
|
||||
if (strpos($component, '.') !== false) {
|
||||
list($plugin, $component) = explode('.', $component);
|
||||
$plugin = $plugin . '.';
|
||||
}
|
||||
$componentCn = $component . 'Component';
|
||||
|
||||
if (!class_exists($componentCn)) {
|
||||
if (is_null($plugin) || !App::import('Component', $plugin . $component)) {
|
||||
if (!App::import('Component', $component)) {
|
||||
$this->cakeError('missingComponentFile', array(array(
|
||||
'className' => $this->__controllerVars['name'],
|
||||
'component' => $component,
|
||||
'file' => Inflector::underscore($component) . '.php',
|
||||
'base' => $base,
|
||||
'code' => 500
|
||||
)));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists($componentCn)) {
|
||||
$this->cakeError('missingComponentClass', array(array(
|
||||
if (!class_exists($componentCn)) {
|
||||
if (is_null($plugin) || !App::import('Component', $plugin . $component)) {
|
||||
if (!App::import('Component', $component)) {
|
||||
$this->cakeError('missingComponentFile', array(array(
|
||||
'className' => $this->__controllerVars['name'],
|
||||
'component' => $component,
|
||||
'file' => Inflector::underscore($component) . '.php',
|
||||
|
@ -222,34 +208,45 @@ class Component extends Object {
|
|||
}
|
||||
}
|
||||
|
||||
if ($parent === null) {
|
||||
$this->_primary[] = $component;
|
||||
if (!class_exists($componentCn)) {
|
||||
$this->cakeError('missingComponentClass', array(array(
|
||||
'className' => $this->__controllerVars['name'],
|
||||
'component' => $component,
|
||||
'file' => Inflector::underscore($component) . '.php',
|
||||
'base' => $base,
|
||||
'code' => 500
|
||||
)));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->_loaded[$component])) {
|
||||
$object->{$component} =& $this->_loaded[$component];
|
||||
if ($parent === null) {
|
||||
$this->_primary[] = $component;
|
||||
}
|
||||
|
||||
if (!empty($config) && isset($this->__settings[$component])) {
|
||||
$this->__settings[$component] = array_merge($this->__settings[$component], $config);
|
||||
} elseif (!empty($config)) {
|
||||
$this->__settings[$component] = $config;
|
||||
}
|
||||
if (isset($this->_loaded[$component])) {
|
||||
$object->{$component} =& $this->_loaded[$component];
|
||||
|
||||
if (!empty($config) && isset($this->__settings[$component])) {
|
||||
$this->__settings[$component] = array_merge($this->__settings[$component], $config);
|
||||
} elseif (!empty($config)) {
|
||||
$this->__settings[$component] = $config;
|
||||
}
|
||||
} else {
|
||||
if ($componentCn === 'SessionComponent') {
|
||||
$object->{$component} =& new $componentCn($base);
|
||||
} else {
|
||||
if ($componentCn === 'SessionComponent') {
|
||||
$object->{$component} =& new $componentCn($base);
|
||||
} else {
|
||||
$object->{$component} =& new $componentCn();
|
||||
}
|
||||
$object->{$component}->enabled = true;
|
||||
$this->_loaded[$component] =& $object->{$component};
|
||||
if (!empty($config)) {
|
||||
$this->__settings[$component] = $config;
|
||||
}
|
||||
$object->{$component} =& new $componentCn();
|
||||
}
|
||||
$object->{$component}->enabled = true;
|
||||
$this->_loaded[$component] =& $object->{$component};
|
||||
if (!empty($config)) {
|
||||
$this->__settings[$component] = $config;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($object->{$component}->components) && is_array($object->{$component}->components) && (!isset($object->{$component}->{$parent}))) {
|
||||
$this->_loadComponents($object->{$component}, $component);
|
||||
}
|
||||
if (isset($object->{$component}->components) && is_array($object->{$component}->components) && (!isset($object->{$component}->{$parent}))) {
|
||||
$this->_loadComponents($object->{$component}, $component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -363,7 +363,7 @@ class Controller extends Object {
|
|||
}
|
||||
|
||||
foreach ($merge as $var) {
|
||||
if (isset($appVars[$var]) && !empty($appVars[$var]) && is_array($this->{$var})) {
|
||||
if (!empty($appVars[$var]) && is_array($this->{$var})) {
|
||||
if ($var === 'components') {
|
||||
$normal = Set::normalize($this->{$var});
|
||||
$app = Set::normalize($appVars[$var]);
|
||||
|
|
|
@ -864,7 +864,7 @@ class ControllerTest extends CakeTestCase {
|
|||
$Controller->uses = array();
|
||||
$Controller->constructClasses();
|
||||
|
||||
$this->assertEqual($Controller->components, array('Session'));
|
||||
$this->assertTrue(isset($Controller->Session));
|
||||
}
|
||||
/**
|
||||
* testReferer method
|
||||
|
|
Loading…
Reference in a new issue