From 013c05b5aa2669926d8d3ef0227a8951105f6781 Mon Sep 17 00:00:00 2001 From: zYne Date: Wed, 20 Sep 2006 21:29:50 +0000 Subject: [PATCH] Refactored Doctrine::loadAll() --- Doctrine.php | 46 ++++++------------------------------------- Doctrine/Compiler.php | 9 +++++++++ 2 files changed, 15 insertions(+), 40 deletions(-) diff --git a/Doctrine.php b/Doctrine.php index 753af8674..1dcb93fd9 100644 --- a/Doctrine.php +++ b/Doctrine.php @@ -286,6 +286,7 @@ final class Doctrine { */ private static $path; /** + * getPath * returns the doctrine root * * @return string @@ -297,51 +298,16 @@ final class Doctrine { return self::$path; } /** + * loadAll * loads all runtime classes * * @return void */ public static function loadAll() { - if(! self::$path) - self::$path = dirname(__FILE__); + $classes = Doctrine_Compiler::getRuntimeClasses(); - $path = self::$path.DIRECTORY_SEPARATOR."Doctrine"; - $dir = dir($path); - $a = array(); - while (false !== ($entry = $dir->read())) { - switch($entry): - case ".": - case "..": - break; - case "Cache": - case "Record": - case "Collection": - case "Table": - case "Validator": - case "Exception": - case "EventListener": - case "Session": - case "DQL": - case "Sensei": - case "Iterator": - case "View": - case "Query": - $a[] = $path.DIRECTORY_SEPARATOR.$entry; - break; - default: - if(is_file($path.DIRECTORY_SEPARATOR.$entry) && substr($entry,-4) == ".php") { - require_once($path.DIRECTORY_SEPARATOR.$entry); - } - endswitch; - } - foreach($a as $dirname) { - $dir = dir($dirname); - $path = $dirname.DIRECTORY_SEPARATOR; - while (false !== ($entry = $dir->read())) { - if(is_file($path.$entry) && substr($entry,-4) == ".php") { - require_once($path.$entry); - } - } + foreach($classes as $class) { + Doctrine::autoload($class); } } /** @@ -354,7 +320,7 @@ final class Doctrine { */ public static function compile() { Doctrine_Compiler::compile(); - } + } /** * simple autoload function * returns true if the class was loaded, otherwise false diff --git a/Doctrine/Compiler.php b/Doctrine/Compiler.php index bc02c6b5e..51842c78e 100644 --- a/Doctrine/Compiler.php +++ b/Doctrine/Compiler.php @@ -64,6 +64,15 @@ class Doctrine_Compiler { "DB", "DBStatement"); + /** + * getRuntimeClasses + * returns an array containing all runtime classes of Doctrine framework + * + * @return array + */ + public static function getRuntimeClasses() { + return self::$classes; + } /** * method for making a single file of most used doctrine runtime components * including the compiled file instead of multiple files (in worst