Example #1
0
 /**
  * 加载应用配置文件
  *
  * 加载应用配置文件,分析该配置文件内容,并将分析后的数据赋值给self::$_data。
  *
  * @access public
  *
  * @param string $filePath 应用配置文件路径
  *
  * @return boolean
  */
 public static function loadConfig($filePath = null)
 {
     //判断本方法是否被调用过,如果调用过,则直接返回。
     if (self::$_isStart == true) {
         return true;
     }
     //获取应用配置文件内容默认值
     $defaultConfig = self::_getDefaultConfig();
     $config = array();
     //当配置文件路径存在时
     if ($filePath) {
         //分析配置文件是否存在
         if (!is_file($filePath)) {
             Controller::halt('The configuration file: ' . $filePath . ' is not found!', 'Normal');
         }
         //获取应用配置文件内容
         include_once $filePath;
         //应用配置文件内容的默认值与配置文件值进行整合
         $config['application'] = isset($config['application']) && is_array($config['application']) ? $config['application'] + $defaultConfig : $defaultConfig;
     } else {
         $config['application'] = $defaultConfig;
     }
     self::$_data = $config;
     self::$_isStart = true;
     return true;
 }