Commit 013c05b5 authored by zYne's avatar zYne

Refactored Doctrine::loadAll()

parent 0921d1db
...@@ -286,6 +286,7 @@ final class Doctrine { ...@@ -286,6 +286,7 @@ final class Doctrine {
*/ */
private static $path; private static $path;
/** /**
* getPath
* returns the doctrine root * returns the doctrine root
* *
* @return string * @return string
...@@ -297,51 +298,16 @@ final class Doctrine { ...@@ -297,51 +298,16 @@ final class Doctrine {
return self::$path; return self::$path;
} }
/** /**
* loadAll
* loads all runtime classes * loads all runtime classes
* *
* @return void * @return void
*/ */
public static function loadAll() { public static function loadAll() {
if(! self::$path) $classes = Doctrine_Compiler::getRuntimeClasses();
self::$path = dirname(__FILE__);
$path = self::$path.DIRECTORY_SEPARATOR."Doctrine"; foreach($classes as $class) {
$dir = dir($path); Doctrine::autoload($class);
$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);
}
}
} }
} }
/** /**
......
...@@ -64,6 +64,15 @@ class Doctrine_Compiler { ...@@ -64,6 +64,15 @@ class Doctrine_Compiler {
"DB", "DB",
"DBStatement"); "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 * method for making a single file of most used doctrine runtime components
* including the compiled file instead of multiple files (in worst * including the compiled file instead of multiple files (in worst
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment