1 | <?php |
||
15 | final class CommandEventDispatcher implements CommandDispatcherInterface, EventDispatcherInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var CommandDispatcherInterface |
||
19 | */ |
||
20 | private $commandDispatcher; |
||
21 | /** |
||
22 | * @var EventDispatcherInterface |
||
23 | */ |
||
24 | private $eventDispatcher; |
||
25 | |||
26 | /** |
||
27 | * @param CommandDispatcherInterface $commandDispatcher |
||
28 | * @param EventDispatcherInterface $eventDispatcher |
||
29 | */ |
||
30 | public function __construct( |
||
37 | |||
38 | /** |
||
39 | * Try to handle the command given in argument. |
||
40 | * It will look over every handlers registered and find the one that knows how handle it. |
||
41 | * |
||
42 | * @param AbstractCommand $command |
||
43 | * |
||
44 | * @return AbstractCommand |
||
45 | */ |
||
46 | public function handle(AbstractCommand $command) |
||
58 | |||
59 | /** |
||
60 | * Register a CommandHandler for one or more Command. |
||
61 | * |
||
62 | * @param CommandHandlerInterface $handler |
||
63 | * |
||
64 | * @return void |
||
65 | */ |
||
66 | public function register(CommandHandlerInterface $handler) |
||
70 | |||
71 | /** |
||
72 | * @param AbstractEvent $event |
||
73 | * @param bool $asynchronous |
||
74 | * |
||
75 | * @return AbstractEvent |
||
76 | */ |
||
77 | public function publish(AbstractEvent $event, $asynchronous = false) |
||
81 | |||
82 | /** |
||
83 | * @param EventSubscriberInterface $subscriber |
||
84 | */ |
||
85 | public function subscribe(EventSubscriberInterface $subscriber) |
||
89 | |||
90 | /** |
||
91 | * @param AbstractCommand $command |
||
92 | * |
||
93 | * @return AbstractEvent[] |
||
94 | */ |
||
95 | private function extractEventsFromCommand(AbstractCommand $command) |
||
104 | } |
||
105 |