Skip to content

Commit

Permalink
优化当配置文件存在,插件不存在时,钩子异常问题
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaobo.sun committed Oct 13, 2016
1 parent 4e6bfa2 commit 72ce666
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
} else {
$values = (array)$values;
}
$addons[$key] = array_map('get_addon_class', $values);
$addons[$key] = array_filter(array_map('get_addon_class', $values));
\think\Hook::add($key, $addons[$key]);
}
cache('hooks', $addons);
Expand Down Expand Up @@ -70,13 +70,13 @@ function get_addon_class($name, $type = 'hook')
{
switch ($type) {
case 'controller':
$namespace = "\\addons\\" . strtolower($name) . "\\controller";
$namespace = "\\addons\\" . strtolower($name) . "\\controller\\";
break;
default:
$namespace = "\\addons\\" . strtolower($name) . "\\" . ucfirst(strtolower($name));
}

return $namespace;
return class_exists($namespace) ? $namespace : '';
}

/**
Expand Down

0 comments on commit 72ce666

Please sign in to comment.