完善config类的load方法

This commit is contained in:
thinkphp
2015-12-09 22:52:22 +08:00
parent e970a2974a
commit 4eb69edf46

View File

@@ -33,6 +33,7 @@ class Config
if (empty($type)) { if (empty($type)) {
$type = substr(strrchr($config, '.'), 1); $type = substr(strrchr($config, '.'), 1);
} }
$range = $range ? $range : self::$range;
$class = '\\think\\config\\driver\\' . strtolower($type); $class = '\\think\\config\\driver\\' . strtolower($type);
self::set((new $class())->parse($config), '', $range); self::set((new $class())->parse($config), '', $range);
} }
@@ -40,7 +41,8 @@ class Config
// 加载配置文件 // 加载配置文件
public static function load($file, $name = '', $range = '') public static function load($file, $name = '', $range = '')
{ {
$file = strpos($file, '.') ? $file : APP_PATH . $file . EXT; $range = $range ? $range : self::$range;
$file = strpos($file, '.') ? $file : APP_PATH . $file . EXT;
if (!isset(self::$config[$range])) { if (!isset(self::$config[$range])) {
self::$config[$range] = []; self::$config[$range] = [];
} }