Exemple #1
0
 /**
  * 两种加载模式
  * @param $class_name
  * @throws Exception
  */
 public static function autoLoadHandler($class_name)
 {
     if (isset(Flow::$classMap[$class_name])) {
         include Flow::$classMap[$class_name];
         return;
     }
     if (strpos($class_name, "_") !== false) {
         $paths = explode("_", $class_name);
         if (isset($paths[0])) {
             if ($paths[0] == "F") {
                 $paths[0] = "system";
             }
             $paths[0] = Flow::getPathOfAlias($paths[0]);
             $lastp = $paths[count($paths) - 1];
             unset($paths[count($paths) - 1]);
             foreach ($paths as $i => $path_seg) {
                 if ($i != 0) {
                     $paths[$i] = strtolower($path_seg);
                 }
             }
             $file_path = implode(DIRECTORY_SEPARATOR, $paths) . DIRECTORY_SEPARATOR . $lastp . ".php";
             if (DEV_MODE) {
                 if (!file_exists($file_path)) {
                     throw new Exception("Class {$class_name} LoadError" . PHP_EOL . "File {$file_path} Not Existed");
                 }
             }
             include $file_path;
         }
     }
 }