Skip to content

Commit

Permalink
Fix regression caused by PR #6942.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Jul 17, 2015
1 parent 0c09f0d commit 9b857d0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/Core/ObjectRegistry.php
Expand Up @@ -69,10 +69,11 @@ abstract class ObjectRegistry
*/
public function load($objectName, $config = [])
{
if (empty($config) && !isset($this->_loaded[$objectName])) {
list(, $name) = pluginSplit($objectName);
} else {
if (is_array($config) && isset($config['className'])) {
$name = $objectName;
$objectName = $config['className'];
} else {
list(, $name) = pluginSplit($objectName);
}

$loaded = isset($this->_loaded[$name]);
Expand All @@ -83,9 +84,6 @@ public function load($objectName, $config = [])
return $this->_loaded[$name];
}

if (is_array($config) && isset($config['className'])) {
$objectName = $config['className'];
}
$className = $this->_resolveClassName($objectName);
if (!$className || (is_string($className) && !class_exists($className))) {
list($plugin, $objectName) = pluginSplit($objectName);
Expand Down
11 changes: 10 additions & 1 deletion tests/TestCase/ORM/BehaviorRegistryTest.php
Expand Up @@ -110,7 +110,16 @@ public function testLoadPlugin()
{
Plugin::load('TestPlugin');
$result = $this->Behaviors->load('TestPlugin.PersisterOne');
$this->assertInstanceOf('TestPlugin\Model\Behavior\PersisterOneBehavior', $result);

$expected = 'TestPlugin\Model\Behavior\PersisterOneBehavior';
$this->assertInstanceOf($expected, $result);
$this->assertInstanceOf($expected, $this->Behaviors->PersisterOne);

$this->Behaviors->unload('PersisterOne');

$result = $this->Behaviors->load('TestPlugin.PersisterOne', ['foo' => 'bar']);
$this->assertInstanceOf($expected, $result);
$this->assertInstanceOf($expected, $this->Behaviors->PersisterOne);
}

/**
Expand Down

0 comments on commit 9b857d0

Please sign in to comment.