Skip to content

Commit

Permalink
precall 结果支持注入参数
Browse files Browse the repository at this point in the history
  • Loading branch information
kiss291323003 committed Mar 18, 2024
1 parent 8d175ed commit 98b72a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/AnnotationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
4 changes: 3 additions & 1 deletion src/Attributes/PreCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 98b72a2

Please sign in to comment.