function _getClass($type, $name) { $_this =& ClassCollection::getInstance(); $options = $_this->getOption($type, $name); $res = array('class' => null, 'import' => array(), 'isParent' => false); if (!empty($options['parent'])) { $inerit = array_intersect_key($options, array_flip($_this->parentInerit)); $parentOpt = Set::Merge($inerit, $options['parent']); $parent = $_this->_getClass(null, $parentOpt); if (empty($parent)) { return null; } else { $res['import'] = $parent['import']; } } $importOpt = $_this->parseImportOption($options); foreach ($importOpt['search'] as $plugin => $search) { foreach ($search as $path) { $iopt = $importOpt; $iopt['search'] = $path; if (App::import($iopt)) { $res['import'][] = $iopt; $res['class'] = $iopt['name']; $res['plugin'] = $plugin == 'app' ? null : $plugin; break 2; } } } if (!$res['class']) { if (!empty($parent) && $options['defaultByParent']) { $res['isParent'] = true; $res['class'] = $parent['class']; $res['plugin'] = $parent['plugin']; } elseif ($options['throwException']) { return array('error' => array('%name% not found.', array('%name%' => $importOpt['name']))); } else { return null; } } return $res; }
function getClass($type, $name, &$isParent = false) { $_this =& ClassCollection::getInstance(); $options = $_this->getOption($type, $name); if (!empty($options['parent'])) { $inerit = array_intersect_key($options, array_flip($_this->parentInerit)); $parentOpt = Set::Merge($inerit, $options['parent']); $parent = $_this->getClass(null, $parentOpt); if (empty($parent)) { return null; } } $importOpt = $_this->parseImportOption($options); //debug($importOpt); if (App::import($importOpt)) { return $importOpt['name']; } else { if (!empty($parent) && $options['defaultByParent']) { $isParent = true; return $parent; } if ($options['throwException']) { debug($importOpt['name'] . ' not found.'); } return null; } }