small refactoring for the ClassRegistry

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7656 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
renan.saddam 2008-09-24 13:37:06 +00:00
parent 5aade5b581
commit 3f8c959ab3

View file

@ -111,13 +111,13 @@ class ClassRegistry {
$count = count($objects); $count = count($objects);
foreach ($objects as $key => $settings) { foreach ($objects as $key => $settings) {
if (is_array($settings)) { if (is_array($settings)) {
$plugin = null; $plugin = $pluginPath = null;
$settings = array_merge($defaults, $settings); $settings = array_merge($defaults, $settings);
$class = $settings['class']; $class = $settings['class'];
if (strpos($class, '.') !== false) { if (strpos($class, '.') !== false) {
list($plugin, $class) = explode('.', $class); list($plugin, $class) = explode('.', $class);
$plugin = $plugin . '.'; $pluginPath = $plugin . '.';
} }
if (empty($settings['alias'])) { if (empty($settings['alias'])) {
@ -130,10 +130,9 @@ class ClassRegistry {
return $model; return $model;
} }
if (class_exists($class) || App::import($type, $plugin . $class)) { if (class_exists($class) || App::import($type, $pluginPath . $class)) {
${$class} =& new $class($settings); ${$class} =& new $class($settings);
} elseif ($type === 'Model') { } elseif ($type === 'Model') {
$plugin = substr($plugin, 0, -1);
if ($plugin && class_exists($plugin . 'AppModel')) { if ($plugin && class_exists($plugin . 'AppModel')) {
$appModel = $plugin . 'AppModel'; $appModel = $plugin . 'AppModel';
} else { } else {