1 | <?php |
||
17 | class TransactionalCommand implements \IteratorAggregate, ContextualCommandInterface |
||
18 | { |
||
19 | /** |
||
20 | * Nested commands. |
||
21 | * |
||
22 | * @var CommandInterface[] |
||
23 | */ |
||
24 | private $commands = []; |
||
25 | |||
26 | /** |
||
27 | * @var ContextualCommandInterface |
||
28 | */ |
||
29 | private $leadingCommand; |
||
30 | |||
31 | /** |
||
32 | * {@inheritdoc} |
||
33 | */ |
||
34 | public function addCommand(CommandInterface $command, bool $leading = false) |
||
50 | |||
51 | /** |
||
52 | * {@inheritdoc} |
||
53 | */ |
||
54 | public function getLeading(): ContextualCommandInterface |
||
62 | |||
63 | /** |
||
64 | * {@inheritdoc} |
||
65 | */ |
||
66 | public function isEmpty(): bool |
||
70 | |||
71 | /** |
||
72 | * {@inheritdoc} |
||
73 | */ |
||
74 | public function getContext(): array |
||
78 | |||
79 | /** |
||
80 | * {@inheritdoc} |
||
81 | */ |
||
82 | public function addContext(string $name, $value) |
||
86 | |||
87 | /** |
||
88 | * @return mixed|null |
||
89 | */ |
||
90 | public function primaryKey() |
||
94 | |||
95 | /** |
||
96 | * {@inheritdoc} |
||
97 | */ |
||
98 | public function getIterator() |
||
108 | |||
109 | /** |
||
110 | * Closure to be called after command executing. |
||
111 | * |
||
112 | * @param \Closure $closure |
||
113 | */ |
||
114 | final public function onExecute(\Closure $closure) |
||
118 | |||
119 | /** |
||
120 | * To be called after parent transaction been commited. |
||
121 | * |
||
122 | * @param \Closure $closure |
||
123 | */ |
||
124 | final public function onComplete(\Closure $closure) |
||
128 | |||
129 | /** |
||
130 | * To be called after parent transaction been rolled back. |
||
131 | * |
||
132 | * @param \Closure $closure |
||
133 | */ |
||
134 | final public function onRollBack(\Closure $closure) |
||
138 | |||
139 | /** |
||
140 | * {@inheritdoc} |
||
141 | */ |
||
142 | public function execute() |
||
146 | |||
147 | /** |
||
148 | * {@inheritdoc} |
||
149 | */ |
||
150 | public function complete() |
||
154 | |||
155 | /** |
||
156 | * {@inheritdoc} |
||
157 | */ |
||
158 | public function rollBack() |
||
162 | } |
||
163 |