From f7e65f4f4bf687405f77ebe40a2371dcb0cf91c8 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 21 Sep 2016 17:41:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88extra=5Fconfig=5Flist?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=8F=82=E6=95=B0=20=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E7=9B=B4=E6=8E=A5=E6=94=BE?= =?UTF-8?q?=E5=88=B0=20extra=E7=9B=AE=E5=BD=95=E4=B8=8B=E9=9D=A2=E5=8D=B3?= =?UTF-8?q?=E5=8F=AF=E8=87=AA=E5=8A=A8=E5=8A=A0=E8=BD=BD=20=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E4=B8=8D=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- convention.php | 2 -- library/think/App.php | 16 +++++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/convention.php b/convention.php index 133dbd36..83431ab3 100644 --- a/convention.php +++ b/convention.php @@ -19,8 +19,6 @@ return [ 'auto_bind_module' => false, // 注册的根命名空间 'root_namespace' => [], - // 扩展配置文件 - 'extra_config_list' => ['database', 'validate'], // 扩展函数文件 'extra_file_list' => [THINK_PATH . 'helper' . EXT], // 默认输出类型 diff --git a/library/think/App.php b/library/think/App.php index 12748712..95ef5e50 100644 --- a/library/think/App.php +++ b/library/think/App.php @@ -444,12 +444,18 @@ class App $path = APP_PATH . $module; // 加载模块配置 $config = Config::load(CONF_PATH . $module . 'config' . CONF_EXT); - + // 读取数据库配置文件 + $filename = CONF_PATH . $module . 'database' . CONF_EXT; + Config::load($filename, 'database'); // 读取扩展配置文件 - if ($config['extra_config_list']) { - foreach ($config['extra_config_list'] as $name => $file) { - $filename = CONF_PATH . $module . $file . CONF_EXT; - Config::load($filename, is_string($name) ? $name : pathinfo($filename, PATHINFO_FILENAME)); + if (is_dir(CONF_PATH . $module . 'extra')) { + $path = CONF_PATH . $module . 'extra'; + $files = scandir($path); + foreach ($files as $file) { + if (strpos($file, CONF_EXT)) { + $filename = $path . DS . $file; + Config::load($filename, pathinfo($file, PATHINFO_FILENAME)); + } } }