wip
This commit is contained in:
@@ -14,5 +14,5 @@ namespace Zapoyok\CQRSBundle\Command;
|
||||
|
||||
interface CommandBusInterface
|
||||
{
|
||||
public function dispatch(CommandInterface $command): void;
|
||||
public function dispatch(CommandInterface $command): mixed;
|
||||
}
|
||||
|
||||
@@ -12,19 +12,24 @@ declare(strict_types=1);
|
||||
|
||||
namespace Zapoyok\CQRSBundle\Command;
|
||||
|
||||
use Symfony\Component\Messenger\HandleTrait;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
use Symfony\Component\Messenger\Stamp\HandledStamp;
|
||||
|
||||
final class MessengerCommandBus implements CommandBusInterface
|
||||
{
|
||||
private MessageBusInterface $commandBus;
|
||||
|
||||
public function __construct(MessageBusInterface $commandBus)
|
||||
{
|
||||
$this->commandBus = $commandBus;
|
||||
use HandleTrait;
|
||||
|
||||
public function __construct( MessageBusInterface $commandBus, ) {
|
||||
$this->messageBus = $commandBus;
|
||||
}
|
||||
|
||||
public function dispatch(CommandInterface $command): void
|
||||
public function dispatch(CommandInterface $command): mixed
|
||||
{
|
||||
$this->commandBus->dispatch($command);
|
||||
$envelope = $this->messageBus->dispatch($command);
|
||||
return $envelope->last(HandledStamp::class)->getResult();
|
||||
|
||||
// $this->commandBus->dispatch($command);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,17 +17,15 @@ use Symfony\Component\Messenger\MessageBusInterface;
|
||||
|
||||
final class MessengerQueryBus implements QueryBusInterface
|
||||
{
|
||||
use HandleTrait {
|
||||
handle as handleQuery;
|
||||
}
|
||||
use HandleTrait ;
|
||||
|
||||
public function __construct(MessageBusInterface $queryBus)
|
||||
{
|
||||
|
||||
public function __construct( MessageBusInterface $queryBus, ) {
|
||||
$this->messageBus = $queryBus;
|
||||
}
|
||||
|
||||
public function ask(QueryInterface $query): mixed
|
||||
{
|
||||
return $this->handleQuery($query);
|
||||
return $this->handle($query);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
->exclude([
|
||||
__DIR__,
|
||||
__DIR__.'/../../../src/ZapoyokCQRSBundle.php',
|
||||
__DIR__.'/../../../src/MessageId.php',
|
||||
__DIR__.'/../../../src/{DependencyInjection}',
|
||||
])
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user