Esempio n. 1
0
 /**
  * 实例化一个loader
  * @param type $renew               是否强制重新new一个loader,默认只会new一次
  * @param type $hmvc_module_floder  hmvc模块文件夹名称
  * @return type CoreLoader
  */
 public static function instance($renew = null, $hmvc_module_floder = null)
 {
     $default = CoreLoader::$system;
     if (!empty($hmvc_module_floder)) {
         CoreRouter::switchHmvcConfig($hmvc_module_floder);
     }
     //在plugin模式下,路由器不再使用,那么自动注册不会被执行,自动加载功能会失效,所以在这里再尝试加载一次,
     //如此一来就能满足两种模式
     self::classAutoloadRegister();
     //这里调用控制器instance是为了触发自动加载,从而避免了插件模式下,直接instance模型,自动加载失效的问题
     CoreController::instance();
     $renew = is_bool($renew) && $renew === true;
     $ret = empty(self::$instance) || $renew ? self::$instance = new self() : self::$instance;
     CoreLoader::$system = $default;
     return $ret;
 }
Esempio n. 2
0
 public static function setConfig($system)
 {
     CoreLoader::$system = $system;
 }