add plugin loader support

This commit is contained in:
crazywhalecc
2022-12-19 01:45:27 +08:00
parent 52a195aca2
commit cd2bb1b570
18 changed files with 373 additions and 96 deletions

View File

@@ -127,14 +127,18 @@ class AnnotationHandler
// 由于3.0有额外的插件模式支持,所以注解就不再提供独立的闭包函数调用支持了
// 提取要调用的目标类和方法名称
$class = $v->class;
$target_class = new $class();
$target_method = $v->method;
if ($class !== '') {
$target_class = new $class();
$callback = [$target_class, $target_method];
} else {
$callback = $target_method;
}
// 先执行规则失败就返回false
if ($rule_callback !== null && !$rule_callback($v)) {
$this->status = self::STATUS_RULE_FAILED;
return false;
}
$callback = [$target_class, $target_method];
try {
$this->return_val = middleware()->process($callback, ...$args);
} catch (InterruptException $e) {