1 | <?php |
||
10 | class Connection |
||
11 | { |
||
12 | /** |
||
13 | * @var Operation[] |
||
14 | */ |
||
15 | protected $operations = []; |
||
16 | |||
17 | /** |
||
18 | * @var int |
||
19 | */ |
||
20 | protected $idx = 0; |
||
21 | |||
22 | /** |
||
23 | * @var int[] |
||
24 | */ |
||
25 | protected $savePoints = []; |
||
26 | |||
27 | /** |
||
28 | * @var int |
||
29 | */ |
||
30 | protected $depth = 0; |
||
31 | |||
32 | /** |
||
33 | * @var null|string |
||
34 | */ |
||
35 | protected $connectionId; |
||
36 | |||
37 | /** |
||
38 | * Connection constructor. |
||
39 | * |
||
40 | * @param null|string $connectionId |
||
41 | * (optional) The id of the connection. |
||
42 | */ |
||
43 | 1 | public function __construct($connectionId = null) |
|
47 | |||
48 | /** |
||
49 | * Get connection id. |
||
50 | * |
||
51 | * @return null|string |
||
52 | */ |
||
53 | 1 | public function connectionId() |
|
57 | |||
58 | /** |
||
59 | * Get current depth. |
||
60 | * |
||
61 | * @return int |
||
62 | */ |
||
63 | public function getDepth() |
||
67 | |||
68 | /** |
||
69 | * Remove savepoints to and acquire index of latest active savepoint. |
||
70 | * |
||
71 | * @param int $oldDepth |
||
72 | * The old depth. |
||
73 | * @param $newDepth |
||
74 | * The new depth. |
||
75 | * |
||
76 | * @return int|null |
||
77 | * The last index, if found. |
||
78 | */ |
||
79 | 2 | protected function closeSavePoints($oldDepth, $newDepth) |
|
90 | |||
91 | /** |
||
92 | * {@inheritdoc} |
||
93 | */ |
||
94 | 1 | public function startTransaction($newDepth = null) |
|
99 | |||
100 | /** |
||
101 | * {@inheritdoc} |
||
102 | */ |
||
103 | 2 | public function commitTransaction($newDepth = null) |
|
128 | |||
129 | /** |
||
130 | * {@inheritdoc} |
||
131 | */ |
||
132 | 2 | public function rollbackTransaction($newDepth = null) |
|
156 | |||
157 | /** |
||
158 | * {@inheritdoc} |
||
159 | */ |
||
160 | 1 | public function addOperation(Operation $operation) |
|
172 | |||
173 | /** |
||
174 | * {@inheritdoc} |
||
175 | */ |
||
176 | 2 | public function hasOperation(Operation $operation) |
|
180 | |||
181 | /** |
||
182 | * {@inheritdoc} |
||
183 | */ |
||
184 | 1 | public function removeOperation(Operation $operation) |
|
188 | |||
189 | /** |
||
190 | * Short-hand notation for adding code to be run on commit. |
||
191 | * |
||
192 | * @param callable $callback |
||
193 | * The code to run on commit. |
||
194 | * |
||
195 | * @return Operation |
||
196 | */ |
||
197 | 1 | public function onCommit(callable $callback) |
|
202 | |||
203 | /** |
||
204 | * Short-hand notation for adding code to be run on rollback. |
||
205 | * |
||
206 | * @param callable $callback |
||
207 | * The code to run on rollback. |
||
208 | * |
||
209 | * @return Operation |
||
210 | */ |
||
211 | 1 | public function onRollback(callable $callback) |
|
216 | |||
217 | /** |
||
218 | * Short-hand notation for adding code to be run on rollback. |
||
219 | * |
||
220 | * @param mixed $value |
||
221 | * The value to add. |
||
222 | * |
||
223 | * @return Operation |
||
224 | */ |
||
225 | 1 | public function addValue($value) |
|
230 | } |
||
231 |