From c7177f8b72f3a63e3564d044699181349f724a40 Mon Sep 17 00:00:00 2001 From: pandaLIU <563883861@qq.com> Date: Fri, 27 May 2022 00:49:06 +0800 Subject: [PATCH] Fixed DtmMiddleware callback parser --- src/Middleware/DtmMiddleware.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Middleware/DtmMiddleware.php b/src/Middleware/DtmMiddleware.php index 85a740d..a724399 100644 --- a/src/Middleware/DtmMiddleware.php +++ b/src/Middleware/DtmMiddleware.php @@ -46,10 +46,21 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface /** @var Dispatched $dispatched */ $dispatched = $request->getAttribute(Dispatched::class); - if ($dispatched instanceof Dispatched && ! empty($dispatched->handler->callback)) { - [$class, $method] = $dispatched->handler->callback; + $callback = $dispatched->handler->callback; + + if (is_array($callback)) { + [$class, $method] = $callback; + } + + if (is_string($callback) && str_contains($callback, '@')) { + [$class, $method] = explode('@', $callback); + } + if (is_string($callback) && str_contains($callback, '::')) { + [$class, $method] = explode('::', $callback); + } + $barrier = $this->config->get('dtm.barrier.apply', []); $businessCall = function () use ($handler, $request) {