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) |
||
73 | |||
74 | /** |
||
75 | * Dispatch command immediately. |
||
76 | * |
||
77 | * @param MessageInterface $command |
||
78 | * |
||
79 | * @return mixed |
||
80 | * @throws Exception |
||
81 | */ |
||
82 | public function dispatchNow(MessageInterface $command) |
||
95 | |||
96 | /** |
||
97 | * Prepare transaction if possible. |
||
98 | */ |
||
99 | protected function beginTransaction() |
||
105 | |||
106 | /** |
||
107 | * Commit transaction if exist. |
||
108 | */ |
||
109 | protected function commit() |
||
115 | |||
116 | /** |
||
117 | * Rollback transaction if exist. |
||
118 | */ |
||
119 | protected function rollback() |
||
125 | } |
||
126 |