-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathQueryBus.php
More file actions
29 lines (24 loc) · 821 Bytes
/
QueryBus.php
File metadata and controls
29 lines (24 loc) · 821 Bytes
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
<?php
namespace inklabs\kommerce\Lib\Query;
use inklabs\kommerce\Lib\Authorization\AuthorizationContextInterface;
use inklabs\kommerce\Lib\MapperInterface;
class QueryBus implements QueryBusInterface
{
/** @var AuthorizationContextInterface */
private $authorizationContext;
/** @var MapperInterface */
private $mapper;
public function __construct(
AuthorizationContextInterface $authorizationContext,
MapperInterface $mapper
) {
$this->authorizationContext = $authorizationContext;
$this->mapper = $mapper;
}
public function execute(QueryInterface $query): ResponseInterface
{
$handler = $this->mapper->getQueryHandler($query);
$handler->verifyAuthorization($this->authorizationContext);
return $handler->handle();
}
}