mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing ComponentCollecction components loading, as with Behaviors and Helpers, thee MissingFileException can not be thrown
This commit is contained in:
parent
06fb51f19d
commit
4f01fc79c1
2 changed files with 4 additions and 4 deletions
|
@ -79,7 +79,7 @@ class ComponentCollection extends ObjectCollection {
|
||||||
$alias = $component;
|
$alias = $component;
|
||||||
$component = $settings['className'];
|
$component = $settings['className'];
|
||||||
}
|
}
|
||||||
list($plugin, $name) = pluginSplit($component);
|
list($plugin, $name) = pluginSplit($component, true);
|
||||||
if (!isset($alias)) {
|
if (!isset($alias)) {
|
||||||
$alias = $name;
|
$alias = $name;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ class ComponentCollection extends ObjectCollection {
|
||||||
return $this->_loaded[$alias];
|
return $this->_loaded[$alias];
|
||||||
}
|
}
|
||||||
$componentClass = $name . 'Component';
|
$componentClass = $name . 'Component';
|
||||||
App::uses($componentClass, 'Controller/Component');
|
App::uses($componentClass, $plugin . 'Controller/Component');
|
||||||
if (!class_exists($componentClass)) {
|
if (!class_exists($componentClass)) {
|
||||||
throw new MissingComponentClassException(array(
|
throw new MissingComponentClassException(array(
|
||||||
'file' => Inflector::underscore($componentClass) . '.php',
|
'file' => Inflector::underscore($componentClass) . '.php',
|
||||||
|
|
|
@ -84,7 +84,7 @@ class ComponentCollectionTest extends CakeTestCase {
|
||||||
$result = $this->Components->load('Cookie');
|
$result = $this->Components->load('Cookie');
|
||||||
$this->assertInstanceOf('CookieAliasComponent', $result);
|
$this->assertInstanceOf('CookieAliasComponent', $result);
|
||||||
|
|
||||||
App::build(array('plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)));
|
App::build(array('plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)));
|
||||||
$result = $this->Components->load('SomeOther', array('className' => 'TestPlugin.OtherComponent'));
|
$result = $this->Components->load('SomeOther', array('className' => 'TestPlugin.OtherComponent'));
|
||||||
$this->assertInstanceOf('OtherComponentComponent', $result);
|
$this->assertInstanceOf('OtherComponentComponent', $result);
|
||||||
$this->assertInstanceOf('OtherComponentComponent', $this->Components->SomeOther);
|
$this->assertInstanceOf('OtherComponentComponent', $this->Components->SomeOther);
|
||||||
|
@ -109,7 +109,7 @@ class ComponentCollectionTest extends CakeTestCase {
|
||||||
/**
|
/**
|
||||||
* test missingcomponent exception
|
* test missingcomponent exception
|
||||||
*
|
*
|
||||||
* @expectedException MissingComponentFileException
|
* @expectedException MissingComponentClassException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testLoadMissingComponentFile() {
|
function testLoadMissingComponentFile() {
|
||||||
|
|
Loading…
Reference in a new issue