/** * 驱动器方法调用 * @see Core_Template::__get() */ public function __get($driver_name) { $cls = 'Driver_' . ucfirst($driver_name); if (!class_exists($cls)) { throw new Core_Exception('Can\'t found driver:' . $driver_name, App_Key::$ERR_NOT_DRIVER_DEFINED); } //存起来 $ins = Common_Func::get_instance($cls); $this->{$driver_name} = $ins; return $ins; }
/** * 获取template对象 */ public function template_view() { if ($this->_template != null) { return $this->_template; } $temp_name = 'Template_' . App_Info::config('TEMPLATE_TYPE'); $this->_template = Common_Func::get_instance($temp_name); if (!$this->_template) { throw new Core_Exception('Template[' . $temp_name . '] Type Error!', App_Key::$ERR_NOT_DEFINE_TEMPLATE); } return $this->_template; }
/** * * 初始化日志存储方式 * @param $log_type 日志存储方式 * @throws App_Exception * @return class */ private function _init($log_type = '') { if (empty($log_type)) { $config = App_Info::config('LOG_CONFIG'); $log_type = $config['log_type']; } $log_type = ucfirst(strtolower($log_type)); $classname = 'Log_' . $log_type; if (!class_exists($classname)) { throw new App_Exception('类' . $classname . '不存在!', App_Key::$ERROR_KEY); } $class = Common_Func::get_instance($classname); return $class; }
/** * 启用插件 * @param string $plugin 插件模块类名 */ public static function setup_plugin($plugin) { if (is_array($plugin)) { foreach ($plugin as $v) { $ins = Common_Func::get_instance($v); $ins->setup(); } } else { $ins = Common_Func::get_instance($plugin); $ins->setup(); } }