1 | <?php |
||
27 | class CommandBus extends Bus |
||
28 | { |
||
29 | const BUS_NAME = 'bus.command'; |
||
30 | |||
31 | /** |
||
32 | * @var TransactionalInterface |
||
33 | */ |
||
34 | protected $transaction; |
||
35 | |||
36 | /** |
||
37 | * Constructor. |
||
38 | * |
||
39 | * @param TransactionalInterface|null $transaction |
||
40 | */ |
||
41 | public function __construct(TransactionalInterface $transaction = null) |
||
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | public function getName() |
||
53 | |||
54 | /** |
||
55 | * {@inheritdoc} |
||
56 | */ |
||
57 | public function dispatch(MessageInterface $command) |
||
74 | |||
75 | /** |
||
76 | * Dispatch command immediately. |
||
77 | * |
||
78 | * @param MessageInterface $command |
||
79 | * |
||
80 | * @return mixed |
||
81 | * @throws Exception |
||
82 | */ |
||
83 | public function dispatchNow(MessageInterface $command) |
||
96 | |||
97 | /** |
||
98 | * Prepare transaction if possible. |
||
99 | */ |
||
100 | protected function beginTransaction() |
||
106 | |||
107 | /** |
||
108 | * Commit transaction if exist. |
||
109 | */ |
||
110 | protected function commit() |
||
116 | |||
117 | /** |
||
118 | * Rollback transaction if exist. |
||
119 | */ |
||
120 | protected function rollback() |
||
126 | } |
||
127 |