Skip to content

Commit 7c84a41

Browse files
committed
新增param参数绑定
修复开启open_basedir时无法读取插件列表的BUG
1 parent dc22891 commit 7c84a41

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
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.4",
7+
"version": "1.1.5",
88
"authors": [
99
{
1010
"name": "karsonzhang",

src/addons/Route.php

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,21 @@ public function execute($addon = null, $controller = null, $action = null)
2828
$addon = $addon ? call_user_func($filter, $addon) : '';
2929
$controller = $controller ? call_user_func($filter, $controller) : 'index';
3030
$action = $action ? call_user_func($filter, $action) : 'index';
31-
31+
3232
Hook::listen('addon_begin', $request);
33-
if (!empty($addon) && !empty($controller) && !empty($action))
34-
{
33+
if (!empty($addon) && !empty($controller) && !empty($action)) {
3534
$info = get_addon_info($addon);
36-
if (!$info)
37-
{
35+
if (!$info) {
3836
throw new HttpException(404, __('addon %s not found', $addon));
3937
}
40-
if (!$info['state'])
41-
{
38+
if (!$info['state']) {
4239
throw new HttpException(500, __('addon %s is disabled', $addon));
4340
}
41+
$dispatch = $request->dispatch();
42+
if (isset($dispatch['var']) && $dispatch['var']) {
43+
$request->route($dispatch['var']);
44+
}
45+
4446
// 设置当前请求的控制器、操作
4547
$request->controller($controller)->action($action);
4648

@@ -50,37 +52,29 @@ public function execute($addon = null, $controller = null, $action = null)
5052
Hook::listen('addons_init', $request);
5153

5254
$class = get_addon_class($addon, 'controller', $controller);
53-
if (!$class)
54-
{
55+
if (!$class) {
5556
throw new HttpException(404, __('addon controller %s not found', Loader::parseName($controller, 1)));
5657
}
5758

5859
$instance = new $class($request);
5960

6061
$vars = [];
61-
if (is_callable([$instance, $action]))
62-
{
62+
if (is_callable([$instance, $action])) {
6363
// 执行操作方法
6464
$call = [$instance, $action];
65-
}
66-
elseif (is_callable([$instance, '_empty']))
67-
{
65+
} elseif (is_callable([$instance, '_empty'])) {
6866
// 空操作
6967
$call = [$instance, '_empty'];
7068
$vars = [$action];
71-
}
72-
else
73-
{
69+
} else {
7470
// 操作不存在
7571
throw new HttpException(404, __('addon action %s not found', get_class($instance) . '->' . $action . '()'));
7672
}
7773

7874
Hook::listen('addon_action_begin', $call);
7975

8076
return call_user_func_array($call, $vars);
81-
}
82-
else
83-
{
77+
} else {
8478
abort(500, lang('addon can not be empty'));
8579
}
8680
}

src/common.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ function get_addon_list()
118118
foreach ($results as $name) {
119119
if ($name === '.' or $name === '..')
120120
continue;
121+
if (is_file(ADDON_PATH . $name))
122+
continue;
121123
$addonDir = ADDON_PATH . $name . DS;
122124
if (!is_dir($addonDir))
123125
continue;

0 commit comments

Comments
 (0)