-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
QueryMessageBus.php
43 lines (37 loc) · 1001 Bytes
/
QueryMessageBus.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
declare(strict_types=1);
namespace SonsOfPHP\Bridge\Symfony\Cqrs;
use Symfony\Component\Messenger\HandleTrait;
use Symfony\Component\Messenger\MessageBusInterface;
/**
* Query Bus that uses Symfony Messenger.
*
* If using Symfony Framework, add to your services.yaml
* <code>
* SonsOfPHP\Bridge\Symfony\Cqrs\QueryMessageBus:
* arguments: ['@query.bus']
* </code>
*
* @author Joshua Estes <[email protected]>
*
* @see https://symfony.com/doc/current/messenger/multiple_buses.html
* @see https://symfony.com/doc/current/messenger.html
* @see https://symfony.com/doc/current/components/messenger.html
*/
class QueryMessageBus
{
use HandleTrait {
handle as handleQuery;
}
public function __construct(MessageBusInterface $queryBus)
{
$this->messageBus = $queryBus;
}
/**
* Handle the Query and return the results.
*/
public function handle(object $query): mixed
{
return $this->handleQuery($query);
}
}