Skip to content

Commit

Permalink
修复 DtmMiddleware callback 方法的解析
Browse files Browse the repository at this point in the history
Fixed DtmMiddleware callback parser
  • Loading branch information
PandaLIU-1111 authored Jun 15, 2022
2 parents afdf2bf + c7177f8 commit b351211
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Middleware/DtmMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b351211

Please sign in to comment.