read())) { switch($entry): case ".": case "..": break; case "Cache": case "Record": case "Collection": case "Table": case "Validator": case "Exception": case "Session": case "DQL": case "Sensei": $a[] = self::$path.DIRECTORY_SEPARATOR.$entry; break; default: if(is_file(self::$path.DIRECTORY_SEPARATOR.$entry) && substr($entry,-4) == ".php") { require_once($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); } } } } /** * simple autoload function */ public static function autoload($classname) { if(! self::$path) self::$path = dirname(__FILE__); $e = explode("_",$classname); if($e[0] != "Doctrine") return false; if(end($e) != "Exception") { if(count($e) > 2) { array_shift($e); $dir = array_shift($e); $class = self::$path.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR.implode('',$e).".class.php"; } elseif(count($e) > 1) { $class = self::$path.DIRECTORY_SEPARATOR.$e[1].".class.php"; } else return false; } else { $class = self::$path.DIRECTORY_SEPARATOR."Exception".DIRECTORY_SEPARATOR.$e[1].".class.php"; } if( ! file_exists($class)) { return false; } require_once($class); return true; } } ?>