1 | <?php |
||
13 | class CommandBus |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * @var ContainerCommandHandlerMapper |
||
18 | */ |
||
19 | private $handlerMapper; |
||
20 | |||
21 | /** |
||
22 | * @var Middleware[] |
||
23 | */ |
||
24 | private $middleware = []; |
||
25 | |||
26 | |||
27 | /** |
||
28 | * CommandBus constructor. |
||
29 | * |
||
30 | * @param ContainerCommandHandlerMapper $handlerMapper |
||
31 | */ |
||
32 | public function __construct(ContainerCommandHandlerMapper $handlerMapper) |
||
36 | |||
37 | |||
38 | /** |
||
39 | * Добавить доп. обработчик команды (Middleware) |
||
40 | * |
||
41 | * @param Middleware $middleware |
||
42 | */ |
||
43 | public function addMiddleware(Middleware $middleware) |
||
47 | |||
48 | |||
49 | /** |
||
50 | * Handle command |
||
51 | * |
||
52 | * @param Command $command |
||
53 | * @throws \Itmedia\CommandBusBundle\Exception\HandlerNotFoundException |
||
54 | * @throws \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException |
||
55 | * @throws \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException |
||
56 | */ |
||
57 | public function handle(Command $command) |
||
66 | } |
||
67 |