public function __get($file) { if (array_key_exists($file, self::$_c)) { return self::$_c; } $filePath = Yii::getPathOfAlias('application.config.' . $file) . '.php'; if (is_file($filePath)) { $config = (require $filePath); $localConfig = []; $localFilePath = Yii::getPathOfAlias('application.config.' . $file) . '_local.php'; if (is_file($localFilePath)) { $localConfig = (require $localFilePath); } self::$_c = CMap::mergeArray($config, $localConfig); } else { self::$_c = []; } return self::$_c; }
/** * 设置配置 * @param $key * @param null $value * @return array */ public static function set($key, $value = null) { // 设置单个配置 if (is_string($key)) { self::$_c[$key] = $value; } // 多个配置设置合并 if (is_array($key)) { self::$_c = array_merge(self::$_c, $key); } return self::$_c; }