This commit is contained in:
2021-07-12 18:54:52 +08:00
parent 49f358fa93
commit 69e41f4597
+10 -8
View File
@@ -126,12 +126,14 @@ class Node extends HttpService
*/ */
public function createDispatch(): Closure public function createDispatch(): Closure
{ {
return static function () { $application = $this;
return static function () use ($application) {
$dispatchParam = Context::getContext('dispatch-param', [\request()]); $dispatchParam = Context::getContext('dispatch-param', [\request()]);
if (empty($this->_aop) || $this->handler instanceof Closure) { if (empty($application->_aop) || $application->handler instanceof Closure) {
return call_user_func($this->handler, ...$dispatchParam); return call_user_func($application->handler, ...$dispatchParam);
} }
return call_user_func($this->_aop[0], $this->_aop[1], $dispatchParam); $application->_aop[] = $dispatchParam;
return call_user_func(...$application->_aop);
}; };
} }
@@ -148,10 +150,10 @@ class Node extends HttpService
return; return;
} }
$reflect = $aop->getAop($this->handler); $reflect = $aop->getAop($this->handler);
$this->_aop = [
$method = $reflect->getMethod('invoke'); [$reflect->getMethod('invoke'), 'invokeArgs'],
$reflect->newInstance($this->handler)
$this->_aop = [[$method, 'invokeArgs'], $reflect->newInstance($this->handler)]; ];
} }