1 | <?php |
||
10 | class Operation |
||
11 | { |
||
12 | /** |
||
13 | * @var string[] |
||
14 | */ |
||
15 | protected $idx; |
||
16 | |||
17 | /** |
||
18 | * @var callable |
||
19 | */ |
||
20 | protected $commit; |
||
21 | |||
22 | /** |
||
23 | * @var callable |
||
24 | */ |
||
25 | protected $rollback; |
||
26 | |||
27 | /** |
||
28 | * @var mixed |
||
29 | */ |
||
30 | protected $value; |
||
31 | |||
32 | /** |
||
33 | * @var mixed |
||
34 | */ |
||
35 | protected $result; |
||
36 | |||
37 | /** |
||
38 | * Set commit callback. |
||
39 | * |
||
40 | * @param callable $callback |
||
41 | * The callback when this operation is committed. |
||
42 | * |
||
43 | * @return $this |
||
44 | */ |
||
45 | 6 | public function onCommit(callable $callback) |
|
50 | |||
51 | /** |
||
52 | * Set rollback callback. |
||
53 | * |
||
54 | * @param callable $callback |
||
55 | * The callback when this operation is rolled back. |
||
56 | * |
||
57 | * @return $this |
||
58 | */ |
||
59 | 4 | public function onRollback(callable $callback) |
|
64 | |||
65 | /** |
||
66 | * Get commit callback. |
||
67 | * |
||
68 | * @return callable|null |
||
69 | */ |
||
70 | 1 | public function getCommitCallback() |
|
74 | |||
75 | /** |
||
76 | * Get rollback callback. |
||
77 | * |
||
78 | * @return callable|null |
||
79 | */ |
||
80 | 1 | public function getRollbackCallback() |
|
84 | |||
85 | /** |
||
86 | * @param mixed $value |
||
87 | * The value to set. |
||
88 | * |
||
89 | * @return $this |
||
90 | */ |
||
91 | 1 | public function setValue($value) |
|
96 | |||
97 | /** |
||
98 | * Get value. |
||
99 | * |
||
100 | * @return mixed |
||
101 | */ |
||
102 | 1 | public function getValue() |
|
106 | |||
107 | /** |
||
108 | * Get result from callback. |
||
109 | * |
||
110 | * @return mixed |
||
111 | */ |
||
112 | 4 | public function getResult() |
|
116 | |||
117 | /** |
||
118 | * @param Connection $connection |
||
119 | * The connection to use for this id. |
||
120 | * @param string $idx |
||
121 | * The id. |
||
122 | * |
||
123 | * @return $this |
||
124 | */ |
||
125 | 7 | public function setIdx(Connection $connection, $idx) |
|
130 | |||
131 | /** |
||
132 | * Get id. |
||
133 | * |
||
134 | * @param Connection $connection |
||
135 | * The connection to get id from. |
||
136 | * |
||
137 | * @return string|null |
||
138 | */ |
||
139 | 7 | public function idx(Connection $connection) |
|
144 | |||
145 | /** |
||
146 | * Execute commit operation. |
||
147 | * |
||
148 | * @return mixed |
||
149 | */ |
||
150 | 5 | public function commit() |
|
154 | |||
155 | /** |
||
156 | * Execute rollback operation. |
||
157 | * |
||
158 | * @return mixed |
||
159 | */ |
||
160 | 3 | public function rollback() |
|
164 | } |
||
165 |