diff --git a/core/ClassInfo.php b/core/ClassInfo.php index 503df0bab..3e23cf524 100644 --- a/core/ClassInfo.php +++ b/core/ClassInfo.php @@ -12,16 +12,14 @@ class ClassInfo { * @todo Improve documentation */ static function allClasses() { - global $_CLASS_MANIFEST; - return ArrayLib::valuekey(array_keys($_CLASS_MANIFEST)); + return SS_ClassLoader::instance()->allClasses(); } /** * @todo Improve documentation */ static function exists($class) { - global $_CLASS_MANIFEST; - return class_exists($class, false) || array_key_exists(strtolower($class), $_CLASS_MANIFEST); + return SS_ClassLoader::instance()->classExists($class); } /** @@ -126,32 +124,16 @@ class ClassInfo { * @return array Names of all subclasses as an associative array. */ public static function subclassesFor($class) { - global $_ALL_CLASSES; + $descendants = SS_ClassLoader::instance()->getManifest()->getDescendantsOf($class); + $result = array($class => $class); - if (is_object($class)) { - $class = get_class($class); + if ($descendants) { + return $result + ArrayLib::valuekey($descendants); + } else { + return $result; } - - $parents = array($class); - $classes = array($class => $class); - - if (!isset($_ALL_CLASSES['children'][$class])) { - return $classes; - } - - while ($parent = array_shift($parents)) { - foreach ($_ALL_CLASSES['children'][$parent] as $class) { - $classes[$class] = $class; - - if (isset($_ALL_CLASSES['children'][$class])) { - $parents[] = $class; - } - } - } - - return $classes; } - + /** * Returns the passed class name along with all its parent class names in an * array, sorted with the root class first. @@ -185,16 +167,14 @@ class ClassInfo { * classes and not built-in PHP classes. */ static function implementorsOf($interfaceName) { - global $_ALL_CLASSES; - return (isset($_ALL_CLASSES['implementors'][$interfaceName])) ? $_ALL_CLASSES['implementors'][$interfaceName] : false; + return SS_ClassLoader::instance()->getManifest()->getImplementorsOf($interfaceName); } /** * Returns true if the given class implements the given interface */ static function classImplements($className, $interfaceName) { - global $_ALL_CLASSES; - return isset($_ALL_CLASSES['implementors'][$interfaceName][$className]); + return in_array($className, SS_ClassLoader::instance()->getManifest()->getImplementorsOf($interfaceName)); } /** @@ -215,11 +195,11 @@ class ClassInfo { * @return array */ static function classes_for_file($filePath) { - $absFilePath = Director::getAbsFile($filePath); - global $_CLASS_MANIFEST; - + $absFilePath = Director::getAbsFile($filePath); $matchedClasses = array(); - foreach($_CLASS_MANIFEST as $class => $compareFilePath) { + $manifest = SS_ClassLoader::instance()->getManifest()->getClasses(); + + foreach($manifest as $class => $compareFilePath) { if($absFilePath == $compareFilePath) $matchedClasses[] = $class; } @@ -236,11 +216,11 @@ class ClassInfo { * @return array Array of class names */ static function classes_for_folder($folderPath) { - $absFolderPath = Director::getAbsFile($folderPath); - global $_CLASS_MANIFEST; - + $absFolderPath = Director::getAbsFile($folderPath); $matchedClasses = array(); - foreach($_CLASS_MANIFEST as $class => $compareFilePath) { + $manifest = SS_ClassLoader::instance()->getManifest()->getClasses(); + + foreach($manifest as $class => $compareFilePath) { if(stripos($compareFilePath, $absFolderPath) === 0) $matchedClasses[] = $class; } diff --git a/core/Core.php b/core/Core.php index cdb245c03..66060e437 100644 --- a/core/Core.php +++ b/core/Core.php @@ -305,16 +305,10 @@ function getTempFolder($base = null) { } /** - * Return the file where that class is stored. - * - * @param String $className Case-insensitive lookup. - * @return String + * @deprecated 3.0 Please use {@link SS_ClassManifest::getItemPath()}. */ function getClassFile($className) { - global $_CLASS_MANIFEST; - $lClassName = strtolower($className); - if(isset($_CLASS_MANIFEST[$lClassName])) return $_CLASS_MANIFEST[$lClassName]; - else if(isset($_CLASS_MANIFEST[$className])) return $_CLASS_MANIFEST[$className]; + return SS_ClassLoader::instance()->getManifest()->getItemPath($className); } /** diff --git a/core/i18n.php b/core/i18n.php old mode 100755 new mode 100644 index 409d12b2d..a2cfe7d14 --- a/core/i18n.php +++ b/core/i18n.php @@ -1703,11 +1703,11 @@ class i18n extends Object { } // $name is assumed to be a PHP class else { - global $_CLASS_MANIFEST; + $classes = SS_ClassLoader::instance()->getManifest()->getClasses(); if(strpos($name,'_') !== false) $name = strtok($name,'_'); $name = strtolower($name); // Necessary because of r101131 - if(isset($_CLASS_MANIFEST[$name])) { - $path = str_replace('\\','/',Director::makeRelative($_CLASS_MANIFEST[$name])); + if(isset($classes[$name])) { + $path = str_replace('\\','/',Director::makeRelative($classes[$name])); ereg('/([^/]+)/', $path, $module); } } diff --git a/core/model/DatabaseAdmin.php b/core/model/DatabaseAdmin.php index fc62b3810..53f47da66 100644 --- a/core/model/DatabaseAdmin.php +++ b/core/model/DatabaseAdmin.php @@ -91,9 +91,8 @@ class DatabaseAdmin extends Controller { increase_time_limit_to(600); // Get all our classes - ManifestBuilder::create_manifest_file(); - require(MANIFEST_FILE); - + SS_ClassLoader::instance()->getManifest()->regenerate(); + if(isset($_GET['returnURL'])) { echo "

Setting up the database; you will be returned to your site shortly....

"; $this->doBuild(true); diff --git a/dev/ModelViewer.php b/dev/ModelViewer.php index ebf88f570..e23857ee8 100644 --- a/dev/ModelViewer.php +++ b/dev/ModelViewer.php @@ -128,11 +128,12 @@ class ModelViewer_Model extends ViewableData { } function getModule() { - global $_CLASS_MANIFEST; + $classes = SS_ClassLoader::instance()->getManifest()->getClasses(); $className = strtolower($this->className); + if(($pos = strpos($className,'_')) !== false) $className = substr($className,0,$pos); - if(isset($_CLASS_MANIFEST[$className])) { - if(preg_match('/^'.str_replace('/','\/',preg_quote(BASE_PATH)).'\/([^\/]+)\//', $_CLASS_MANIFEST[$className], $matches)) { + if(isset($classes[$className])) { + if(preg_match('/^'.str_replace('/','\/',preg_quote(BASE_PATH)).'\/([^\/]+)\//', $classes[$className], $matches)) { return $matches[1]; } } diff --git a/tests/TokenisedRegularExpressionTest.php b/tests/TokenisedRegularExpressionTest.php index a711958ad..473b5710b 100644 --- a/tests/TokenisedRegularExpressionTest.php +++ b/tests/TokenisedRegularExpressionTest.php @@ -49,7 +49,7 @@ PHP } function testClassDefParser() { - $parser = ManifestBuilder::getClassDefParser(); + $parser = SS_ClassManifest::get_class_parser(); $tokens = $this->getTokens(); @@ -79,7 +79,7 @@ PHP } function testInterfaceDefParser() { - $parser = ManifestBuilder::getInterfaceDefParser(); + $parser = SS_ClassManifest::get_interface_parser(); $tokens = $this->getTokens();