This commit is contained in:
as2252258@163.com
2021-04-21 01:42:43 +08:00
parent 52886be6aa
commit 5cf3596c92
+7 -8
View File
@@ -47,19 +47,18 @@ class Aop extends Component
* @throws ReflectionException
* @throws Exception
*/
final public function dispatch(): mixed
final public function dispatch($handler, ...$params): mixed
{
$get_args = func_get_args();
if (($close = array_shift($get_args)) instanceof \Closure) {
return call_user_func($close, ...$get_args);
if ($handler instanceof \Closure) {
return call_user_func($handler, ...$params);
}
$aopName = get_class($close[0]) . '::' . $close[1];
$aopName = get_class($handler) . '::' . $handler;
if (!isset($this->_aop[$aopName])) {
if (!method_exists($close[0], $close[1])) {
if (!method_exists($handler[0], $handler[1])) {
return response()->close(404);
}
return call_user_func($close, ...$get_args);
return call_user_func($handler, ...$params);
}
$reflect = Snowflake::getDi()->getReflect(current($this->_aop[$aopName]));
@@ -68,7 +67,7 @@ class Aop extends Component
}
$method = $reflect->getMethod('invoke');
return $method->invokeArgs($reflect->newInstance($close), $get_args);
return $method->invokeArgs($reflect->newInstance($handler), $params);
}