From 3802d9626ac6c9faf57382da2d2f741c976c1096 Mon Sep 17 00:00:00 2001 From: byron Date: Tue, 28 Mar 2017 20:34:16 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=96=B0=E5=A2=9E=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E6=8F=92=E4=BB=B6=E9=85=8D=E7=BD=AE=202?= =?UTF-8?q?=E3=80=81=E4=BC=98=E5=8C=96=E4=BA=86debug=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=203=E3=80=81=E8=A7=84=E8=8C=83=E7=BB=9F?= =?UTF-8?q?=E4=B8=80use=E5=91=BD=E5=90=8D=E7=A9=BA=E9=97=B4=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/common.php b/src/common.php index b0995d7..a48072a 100644 --- a/src/common.php +++ b/src/common.php @@ -45,16 +45,24 @@ $config = (array)Config::get('addons'); // 读取插件目录及钩子列表 $base = get_class_methods("\\think\\Addons"); + // 读取插件目录中的php文件 foreach (glob(ADDON_PATH . '*/*.php') as $addons_file) { + // 格式化路径信息 $info = pathinfo($addons_file); + // 获取插件目录名 $name = pathinfo($info['dirname'], PATHINFO_FILENAME); + // 找到插件入口文件 if (strtolower($info['filename']) == strtolower($name)) { + // 读取出所有公共方法 $methods = (array)get_class_methods("\\addons\\" . $name . "\\" . $info['filename']); + // 跟插件基类方法做比对,得到差异结果 $hooks = array_diff($methods, $base); + // 循环将钩子方法写入配置中 foreach ($hooks as $hook) { if (!isset($config['hooks'][$hook])) { $config['hooks'][$hook] = []; } + // 兼容手动配置项 if (is_string($config['hooks'][$hook])) { $config['hooks'][$hook] = explode(',', $config['hooks'][$hook]); }