Skip to content

Commit dc22891

Browse files
committed
新增upgrade方法
修复get_addon_list特殊情况下获取错误的BUG
1 parent 83ae401 commit dc22891

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"homepage": "https://github.com/karsonzhang/fastadmin-addons",
55
"license": "Apache-2.0",
66
"minimum-stability": "dev",
7-
"version": "1.1.3",
7+
"version": "1.1.4",
88
"authors": [
99
{
1010
"name": "karsonzhang",

src/addons/Service.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public static function refresh()
222222
throw new Exception("addons.js文件没有写入权限");
223223
}
224224

225-
$file = APP_PATH . 'extra' . DS . '/addons.php';
225+
$file = APP_PATH . 'extra' . DS . 'addons.php';
226226

227227
$config = get_addon_autoload_config(true);
228228
if ($config['autoload'])
@@ -561,6 +561,25 @@ public static function upgrade($name, $extend = [])
561561

562562
// 导入
563563
Service::importsql($name);
564+
565+
// 执行升级脚本
566+
try
567+
{
568+
$class = get_addon_class($name);
569+
if (class_exists($class))
570+
{
571+
$addon = new $class();
572+
573+
if (method_exists($class, "upgrade"))
574+
{
575+
$addon->upgrade();
576+
}
577+
}
578+
}
579+
catch (Exception $e)
580+
{
581+
throw new Exception($e->getMessage());
582+
}
564583

565584
// 刷新
566585
Service::refresh();

src/common.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function get_addon_list()
118118
foreach ($results as $name) {
119119
if ($name === '.' or $name === '..')
120120
continue;
121-
$addonDir = ADDON_PATH . DS . $name . DS;
121+
$addonDir = ADDON_PATH . $name . DS;
122122
if (!is_dir($addonDir))
123123
continue;
124124

0 commit comments

Comments
 (0)