1 | <?php |
||
19 | class UnitOfWork |
||
20 | { |
||
21 | /** |
||
22 | * @var Registry |
||
23 | */ |
||
24 | private $registry; |
||
25 | |||
26 | /** |
||
27 | * @var Identifier |
||
28 | */ |
||
29 | private $identifier; |
||
30 | |||
31 | /** |
||
32 | * @var ChangeBuilder |
||
33 | */ |
||
34 | private $changeBuilder; |
||
35 | |||
36 | /** |
||
37 | * @var Comparer |
||
38 | */ |
||
39 | private $comparer; |
||
40 | |||
41 | /** |
||
42 | * @var CommandBus |
||
43 | */ |
||
44 | private $commandBus; |
||
45 | |||
46 | /** |
||
47 | * @param Registry $registry |
||
48 | * @param Identifier $identifier |
||
49 | * @param ChangeBuilder $changeBuilder |
||
50 | * @param Comparer $entityComparer |
||
51 | * @param CommandBus $commandBus |
||
52 | */ |
||
53 | public function __construct( |
||
66 | |||
67 | /** |
||
68 | * @param $entity |
||
69 | * @throws InvalidArgumentException |
||
70 | * @throws RuntimeException |
||
71 | * |
||
72 | * @api |
||
73 | */ |
||
74 | public function register($entity) |
||
86 | |||
87 | /** |
||
88 | * @param $entity |
||
89 | * @return bool |
||
90 | * |
||
91 | * @api |
||
92 | */ |
||
93 | public function isRegistered($entity) |
||
97 | |||
98 | /** |
||
99 | * @param $entity |
||
100 | * @throws InvalidArgumentException |
||
101 | * @throws RuntimeException |
||
102 | * |
||
103 | * @api |
||
104 | */ |
||
105 | public function remove($entity) |
||
119 | |||
120 | /** |
||
121 | * @throws InvalidArgumentException |
||
122 | * @throws RuntimeException |
||
123 | * |
||
124 | * @api |
||
125 | */ |
||
126 | public function commit() |
||
146 | |||
147 | /** |
||
148 | * @api |
||
149 | */ |
||
150 | public function rollback() |
||
154 | |||
155 | /** |
||
156 | * @param $entity |
||
157 | * @return int |
||
158 | * @throws InvalidArgumentException |
||
159 | * @throws RuntimeException |
||
160 | */ |
||
161 | private function getEntityState($entity) |
||
185 | |||
186 | /** |
||
187 | * @param $entity |
||
188 | * @return bool |
||
189 | * @throws RuntimeException |
||
190 | */ |
||
191 | private function isChanged($entity) |
||
198 | } |
||
199 |