Changeset 3002 for trunk/lib/Doctrine.php
- Timestamp:
- 10/24/07 22:20:19 (15 months ago)
- Files:
-
- 1 modified
-
trunk/lib/Doctrine.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Doctrine.php
r2989 r3002 434 434 */ 435 435 private static $_debug = false; 436 437 /** 438 * _loadedModels 439 * 440 * Array of all the loaded models and the path to each one for autoloading 441 * 442 * @var string 443 */ 444 private static $_loadedModels = array(); 436 445 437 446 /** … … 549 558 public static function loadModels($directory) 550 559 { 551 $declared = get_declared_classes();552 553 560 if ($directory !== null) { 561 $manager = Doctrine_Manager::getInstance(); 562 554 563 foreach ((array) $directory as $dir) { 555 564 $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), … … 559 568 $e = explode('.', $file->getFileName()); 560 569 if (end($e) === 'php' && strpos($file->getFileName(), '.inc') === false) { 561 require_once$file->getPathName();570 self::$_loadedModels[$e[0]] = $file->getPathName(); 562 571 } 563 572 } 564 573 } 565 566 $declared = array_diff(get_declared_classes(), $declared); 567 } 568 569 return self::getLoadedModels($declared); 574 } 575 576 return self::getLoadedModels(array_keys(self::$_loadedModels)); 570 577 } 571 578 … … 968 975 /** 969 976 * compile 977 * 970 978 * method for making a single file of most used doctrine runtime components 971 979 * including the compiled file instead of multiple files (in worst … … 983 991 984 992 /** 993 * autoload 994 * 985 995 * simple autoload function 986 996 * returns true if the class was loaded, otherwise false … … 989 999 * @return boolean 990 1000 */ 991 public static function autoload($class name)992 { 993 if (class_exists($class name, false)) {1001 public static function autoload($className) 1002 { 1003 if (class_exists($className, false)) { 994 1004 return false; 995 1005 } … … 999 1009 } 1000 1010 1001 $class = self::$_path . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $classname) . '.php'; 1002 1003 if ( ! file_exists($class)) { 1004 return false; 1005 } 1006 1007 require_once($class); 1008 1009 return true; 1011 $class = self::$_path . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; 1012 1013 if (file_exists($class)) { 1014 require_once($class); 1015 1016 return true; 1017 } 1018 1019 $loadedModels = self::$_loadedModels; 1020 1021 if (isset($loadedModels[$className]) && file_exists($loadedModels[$className])) { 1022 require_once($loadedModels[$className]); 1023 1024 return true; 1025 } 1026 1027 return false; 1010 1028 } 1011 1029 … … 1043 1061 1044 1062 /** 1063 * tableize 1064 * 1045 1065 * returns table name from class name 1046 1066 * … … 1054 1074 1055 1075 /** 1076 * classify 1077 * 1056 1078 * returns class name from table name 1057 1079 * … … 1065 1087 1066 1088 /** 1089 * classifyCallback 1090 * 1067 1091 * Callback function to classify a classname propperly. 1068 1092 * … … 1076 1100 1077 1101 /** 1102 * isValidClassName 1103 * 1078 1104 * checks for valid class name (uses camel case and underscores) 1079 1105 * … … 1089 1115 return true; 1090 1116 } 1117 1118 /** 1119 * makeDirectories 1120 * 1121 * Makes the directories for a path recursively 1122 * 1123 * @param string $path 1124 * @return void 1125 */ 1126 public static function makeDirectories($path, $mode = 0777) 1127 { 1128 if (is_dir($path) || is_file($path)) 1129 { 1130 return true; 1131 } 1132 1133 return mkdir($path, $mode, true); 1134 } 1091 1135 }