Exemple #1
0
 public static function autoload($className)
 {
     if (isset(self::$_coreClasses[$className])) {
         require_once PATH_LI . self::$_coreClasses[$className];
     } else {
         // 无命名空间
         if (strpos($className, '\\') === false) {
             if (isset(App::app()->config['import']) && is_array(App::app()->config['import'])) {
                 foreach (\Li\App::app()->config['import'] as $path) {
                     $classFile = PATH_APP . 'core' . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $className . '.php';
                     if (is_file($classFile)) {
                         include $classFile;
                     }
                 }
             }
         } else {
             // 命名空间
             $path = explode('\\', $className);
             $classFile = PATH_APP . 'core' . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $path) . '.php';
             if (is_file($classFile)) {
                 include $classFile;
             }
         }
         return class_exists($className, false) || interface_exists($className, false);
     }
     return true;
 }