1 | <?php |
||
16 | class CommandBusEventDispatcher implements CommandBusInterface, EventBusInterface |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * @var CommandBusInterface |
||
21 | */ |
||
22 | private $commandBus; |
||
23 | |||
24 | /** |
||
25 | * @var EventBusInterface |
||
26 | */ |
||
27 | private $eventBus; |
||
28 | |||
29 | /** |
||
30 | * @param CommandBusInterface $commandBus |
||
31 | * @param EventBusInterface $eventBus |
||
32 | */ |
||
33 | public function __construct(CommandBusInterface $commandBus, EventBusInterface $eventBus) |
||
38 | |||
39 | /** |
||
40 | * @param CommandInterface $command |
||
41 | * |
||
42 | * @return AbstractAggregateRoot[] |
||
43 | */ |
||
44 | public function dispatch(CommandInterface $command) |
||
52 | |||
53 | /** |
||
54 | * @return CommandHandlerInterface[] |
||
55 | */ |
||
56 | public function getRegisteredCommandHandlers() |
||
60 | |||
61 | /** |
||
62 | * Publishes the event $event to every EventListener that wants to. |
||
63 | * |
||
64 | * @param EventInterface $event |
||
65 | * |
||
66 | * @return string[]|null data returned by each EventListener |
||
67 | */ |
||
68 | public function publish(EventInterface $event) |
||
77 | |||
78 | /** |
||
79 | * Get the list of every EventListener defined in the EventBus. |
||
80 | * This might be useful for debug |
||
81 | * |
||
82 | * @return EventListenerCollection[] |
||
83 | */ |
||
84 | public function getRegisteredEventListeners() |
||
88 | |||
89 | /** |
||
90 | * @param array $elements |
||
91 | */ |
||
92 | private function dispatchEvents(array $elements) |
||
105 | |||
106 | /** |
||
107 | * @param AbstractAggregateRoot $aggregateRoot |
||
108 | */ |
||
109 | private function dispatchEventsForAggregateRoot(AbstractAggregateRoot $aggregateRoot) |
||
117 | |||
118 | /** |
||
119 | * @param array $commandsToDispatch |
||
120 | * |
||
121 | * @return CommandInterface[] |
||
122 | */ |
||
123 | private function extractCommands(array $commandsToDispatch) |
||
136 | } |
||
137 |