wip
This commit is contained in:
@@ -14,5 +14,5 @@ namespace Zapoyok\CQRSBundle\Command;
|
|||||||
|
|
||||||
interface CommandBusInterface
|
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;
|
namespace Zapoyok\CQRSBundle\Command;
|
||||||
|
|
||||||
|
use Symfony\Component\Messenger\HandleTrait;
|
||||||
use Symfony\Component\Messenger\MessageBusInterface;
|
use Symfony\Component\Messenger\MessageBusInterface;
|
||||||
|
use Symfony\Component\Messenger\Stamp\HandledStamp;
|
||||||
|
|
||||||
final class MessengerCommandBus implements CommandBusInterface
|
final class MessengerCommandBus implements CommandBusInterface
|
||||||
{
|
{
|
||||||
private MessageBusInterface $commandBus;
|
|
||||||
|
|
||||||
public function __construct(MessageBusInterface $commandBus)
|
use HandleTrait;
|
||||||
{
|
|
||||||
$this->commandBus = $commandBus;
|
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
|
final class MessengerQueryBus implements QueryBusInterface
|
||||||
{
|
{
|
||||||
use HandleTrait {
|
use HandleTrait ;
|
||||||
handle as handleQuery;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __construct(MessageBusInterface $queryBus)
|
|
||||||
{
|
public function __construct( MessageBusInterface $queryBus, ) {
|
||||||
$this->messageBus = $queryBus;
|
$this->messageBus = $queryBus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ask(QueryInterface $query): mixed
|
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([
|
->exclude([
|
||||||
__DIR__,
|
__DIR__,
|
||||||
__DIR__.'/../../../src/ZapoyokCQRSBundle.php',
|
__DIR__.'/../../../src/ZapoyokCQRSBundle.php',
|
||||||
|
__DIR__.'/../../../src/MessageId.php',
|
||||||
__DIR__.'/../../../src/{DependencyInjection}',
|
__DIR__.'/../../../src/{DependencyInjection}',
|
||||||
])
|
])
|
||||||
;
|
;
|
||||||
|
|||||||
Reference in New Issue
Block a user