From 98b72a2d870dcb7e29b709b3133c6635746c8004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=9E=9C=E7=9A=84=E5=A6=82=E6=9E=9C?= Date: Mon, 18 Mar 2024 20:55:13 +0800 Subject: [PATCH] =?UTF-8?q?precall=20=E7=BB=93=E6=9E=9C=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=B3=A8=E5=85=A5=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AnnotationController.php | 3 +++ src/Attributes/PreCall.php | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/AnnotationController.php b/src/AnnotationController.php index 8d24b5a..ad49cb7 100644 --- a/src/AnnotationController.php +++ b/src/AnnotationController.php @@ -89,6 +89,9 @@ public function __hook(?array $actionArg = [],?array $onRequestArg = null) if($ret === false){ return; } + if(!empty($call->injectParamName)){ + $onRequestArg[$call->injectParamName] = $ret; + } } } }catch (\Throwable $exception){ diff --git a/src/Attributes/PreCall.php b/src/Attributes/PreCall.php index 8f0e7c9..0013a04 100644 --- a/src/Attributes/PreCall.php +++ b/src/Attributes/PreCall.php @@ -8,8 +8,10 @@ class PreCall { public $call; - function __construct(callable $call) + public ?string $injectParamName = null; + function __construct(callable $call,string $injectParamName = null) { $this->call = $call; + $this->injectParamName = $injectParamName; } } \ No newline at end of file