Skip to content

Commit

Permalink
fixing handle method return
Browse files Browse the repository at this point in the history
  • Loading branch information
dersonsena committed May 28, 2021
1 parent bdb3d0a commit 73d311c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Yii2TacticianCommandBus.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ public function handle($command, array $parameters = [])

/** @var \DersonSena\Yii2Tactician\Handler $handleObject */
$handleObject = Yii::$container->get($command);

if (!($handleObject instanceof Handle)) {
throw new RuntimeException("Handle class must implements '" . Handle::class . "' interface.");
}

if (!method_exists($handleObject, 'handle')) {
throw new RuntimeException("Handle class '{$handleObject::class}' must be a handle() method.");
}

$commandClass = $handleObject->commandClassName();

if (!class_exists($commandClass)) {
Expand All @@ -62,7 +71,7 @@ public function handle($command, array $parameters = [])
throw new RuntimeException("Command class must implements '" . Command::class . "' interface.");
}

return call_user_func_array($callable, [$command]);
return $handleObject->handle($command);
}

return call_user_func_array($callable, [$command]);
Expand Down

0 comments on commit 73d311c

Please sign in to comment.