示例#1
0
文件: myapp.php 项目: fchaose/qeephp
 /**
  * 构造函数
  *
  * @param array $app_config
  */
 protected function __construct(array $app_config)
 {
     parent::__construct($app_config);
     $root_dir = $app_config['ROOT_DIR'];
     Q::import($root_dir . '/app/model');
     Q::import($root_dir . '/app');
     require_once $root_dir . '/app/controller/abstract.php';
 }
示例#2
0
 /**
  * 构造函数
  *
  * @param array $app_config
  * @param array $managed_app_config
  */
 protected function __construct($app_config, $managed_app_config)
 {
     parent::__construct($app_config);
     $this->managed_app_config = $managed_app_config;
     Q::import($app_config['ROOT_DIR'] . '/app/model');
     Q::import($app_config['ROOT_DIR'] . '/app');
     Q::import(dirname(Q_DIR) . '/extended');
     require $app_config['ROOT_DIR'] . '/app/controller/abstract.php';
 }
示例#3
0
 /**
  * 注册应用程序设置
  *
  * 注册时,如果还没有任何应用程序设置,则注册为默认应用。此时忽略 $default 参数的值。
  * 如果已经注册了应用程序,指定 $default 参数为 true 可以将新注册的应用程序设置为默认应用。
  *
  * @param string $appid
  * @param array $config
  * @param boolean $default
  */
 static function setAppConfig($appid, array $config, $default = false)
 {
     if (empty($appid)) {
         // LC_MSG: Invalid APPID.
         throw new QApplication_Exception(__('Invalid APPID.'));
     }
     if (isset(self::$_app_configs[$appid])) {
         // LC_MSG: Can't register exists APPID "%s".
         throw new QApplication_Exception(__('Can\'t register exists APPID "%s".', $appid));
     }
     $config['APPID'] = $appid;
     self::$_app_configs[$appid] = $config;
     if (is_null(self::$_default_appid) || $default) {
         self::$_default_appid = $appid;
     }
 }
示例#4
0
 /**
  * 构造函数
  *
  * @param array $app_config
  */
 function __construct($app_config)
 {
     $this->_app_config = $app_config;
     $this->_appid = $app_config['APPID'];
     QApplication_Abstract::setAppConfig($this->_appid, $this->_app_config);
 }
示例#5
0
 /**
  * 返回应用程序根目录
  *
  * @return string
  */
 function ROOT_DIR()
 {
     return $this->_app->ROOT_DIR();
 }
示例#6
0
文件: module.php 项目: fchaose/qeephp
 /**
  * 载入模块的配置
  *
  * @return array
  */
 function loadCachedModuleConfig()
 {
     if ($this->_appid == QApplication_Abstract::DEFAULT_APPID) {
         return include Q_DIR . '/_config/default_config.php';
     }
     $app_config = QApplication_Abstract::getAppConfig($this->_appid);
     if (empty($app_config['CONFIG_CACHED'])) {
         // 不使用缓存,直接读取配置文件
         return self::loadModuleConfig($this->_module_name, $app_config);
     }
     // 确定缓存 ID
     $run_mode = !empty($app_config['RUN_MODE']) ? $app_config['RUN_MODE'] : Q::RUN_MODE_DEPLOY;
     if ($this->_module_name) {
         $cache_id = "{$app_config['APPID']}.module.{$this->_module_name}.config.{$run_mode}";
     } else {
         $cache_id = "{$app_config['APPID']}.app.config.{$run_mode}";
     }
     // 如果有必要,构造缓存对象
     if (is_null($this->_cache_backend)) {
         $class = $app_config['CONFIG_CACHE_BACKEND'];
         $default_policy = array('life_time' => $app_config['CONFIG_CACHE_LIFETIME'], 'serialize' => true, 'cache_dir' => $app_config['CONFIG_CACHE_DIR']);
         $this->_cache_backend = new $class($default_policy);
     }
     // 尝试载入缓存的配置信息
     $config = $this->_cache_backend->get($cache_id);
     if (is_array($config)) {
         return $config;
     }
     // 读取并解析配置,然后写入缓存
     $config = self::loadModuleConfig($this->_module_name, $app_config);
     $this->_cache_backend->set($cache_id, $config);
     return $config;
 }