mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-24 17:15:36 +08:00
fix param for annotation handler
This commit is contained in:
@@ -126,7 +126,7 @@ class AnnotationHandler
|
|||||||
* @throws InterruptException
|
* @throws InterruptException
|
||||||
* @throws Throwable
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
public function handle(AnnotationBase $v, ?callable $rule_callback = null): bool
|
public function handle(AnnotationBase $v, ?callable $rule_callback = null, ...$args): bool
|
||||||
{
|
{
|
||||||
// 由于3.0有额外的插件模式支持,所以注解就不再提供独立的闭包函数调用支持了
|
// 由于3.0有额外的插件模式支持,所以注解就不再提供独立的闭包函数调用支持了
|
||||||
// 提取要调用的目标类和方法名称
|
// 提取要调用的目标类和方法名称
|
||||||
@@ -139,7 +139,7 @@ class AnnotationHandler
|
|||||||
}
|
}
|
||||||
$callback = [$target_class, $target_method];
|
$callback = [$target_class, $target_method];
|
||||||
try {
|
try {
|
||||||
$this->return_val = middleware()->process($callback);
|
$this->return_val = middleware()->process($callback, ...$args);
|
||||||
} catch (InterruptException $e) {
|
} catch (InterruptException $e) {
|
||||||
// 这里直接抛出这个异常的目的就是给上层handleAll()捕获
|
// 这里直接抛出这个异常的目的就是给上层handleAll()捕获
|
||||||
throw $e;
|
throw $e;
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ class MiddlewareHandler
|
|||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
* @throws Throwable
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
public function process(callable $callback)
|
public function process(callable $callback, ...$args)
|
||||||
{
|
{
|
||||||
$stack_id = $this->getStackId($callback);
|
$stack_id = $this->getStackId($callback);
|
||||||
unset($this->stack[$stack_id]);
|
unset($this->stack[$stack_id]);
|
||||||
@@ -147,7 +147,7 @@ class MiddlewareHandler
|
|||||||
// 遍历执行before并压栈,并在遇到返回false后停止
|
// 遍历执行before并压栈,并在遇到返回false后停止
|
||||||
try {
|
try {
|
||||||
$mid_list = ($this->reg_map[$stack_id] ?? []);
|
$mid_list = ($this->reg_map[$stack_id] ?? []);
|
||||||
$final_result = ($this->getPipeClosure($callback, $stack_id))($mid_list);
|
$final_result = ($this->getPipeClosure($callback, $stack_id))($mid_list, ...$args);
|
||||||
} finally {
|
} finally {
|
||||||
array_pop($this->callable_stack);
|
array_pop($this->callable_stack);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user