Skip to content

Commit 017e5cc

Browse files
committed
Fix for eventbus and commandbus
1 parent 1164163 commit 017e5cc

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/CommandBus/CommandBus.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ public function __invoke(Command $command, callable $next = null)
3434
$middleware = $this->middleware;
3535
$current = array_shift($middleware);
3636

37+
if (empty($middleware)) {
38+
$current->__invoke($command);
39+
return;
40+
}
41+
3742
foreach ($middleware as $commandBusMiddleware) {
3843
$callable = function ($command) use ($commandBusMiddleware) {
3944
return $commandBusMiddleware($command);

src/EventBus/EventBus.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public function __invoke(Event $event, callable $next = null)
3737
$middleware = $this->middleware;
3838
$current = array_shift($middleware);
3939

40+
if (empty($middleware)) {
41+
$current->__invoke($event);
42+
return;
43+
}
44+
4045
foreach ($middleware as $eventBusMiddleware) {
4146
$callable = function ($event) use ($eventBusMiddleware) {
4247
return $eventBusMiddleware($event);

0 commit comments

Comments
 (0)