1 | <?php |
||
17 | class Repository implements RepositoryInterface |
||
18 | { |
||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $entityName; |
||
23 | |||
24 | /** |
||
25 | * @var CriteriaFactory |
||
26 | */ |
||
27 | protected $criteriaFactory; |
||
28 | |||
29 | /** |
||
30 | * @var TableGateway |
||
31 | */ |
||
32 | protected $tableGateway; |
||
33 | |||
34 | /** |
||
35 | * @var Mapper |
||
36 | */ |
||
37 | protected $mapper; |
||
38 | |||
39 | /** |
||
40 | * @var EntityFactoryInterface |
||
41 | */ |
||
42 | protected $entityFactory; |
||
43 | |||
44 | /** |
||
45 | * @var ArrayObject |
||
46 | */ |
||
47 | protected $identityMap; |
||
48 | |||
49 | /** |
||
50 | * @var ArrayObject |
||
51 | */ |
||
52 | protected $identityMapOriginal; |
||
53 | |||
54 | /** |
||
55 | * @var EventManagerInterface |
||
56 | */ |
||
57 | protected $eventManager; |
||
58 | |||
59 | /** |
||
60 | * @var EntityChangedEvent |
||
61 | */ |
||
62 | protected $event; |
||
63 | |||
64 | /** |
||
65 | * @var string |
||
66 | */ |
||
67 | protected $tablePrimaryKey; |
||
68 | |||
69 | /** |
||
70 | * @param string $entityName |
||
71 | * @param CriteriaFactory $criteriaFactory |
||
72 | * @param TableGateway $tableGateway |
||
73 | * @param Mapper $mapper |
||
74 | * @param EntityFactoryInterface $entityFactory |
||
75 | * @param EventManagerInterface $eventManager |
||
76 | * @param string $tablePrimaryKey |
||
77 | */ |
||
78 | public function __construct( |
||
98 | |||
99 | /** |
||
100 | * @param EntityInterface $entity |
||
101 | * @return EntityInterface|int|null |
||
102 | */ |
||
103 | public function add(EntityInterface $entity) |
||
140 | |||
141 | /** |
||
142 | * @param EntityInterface $entity |
||
143 | * @return int|null |
||
144 | */ |
||
145 | public function remove(EntityInterface $entity) |
||
159 | |||
160 | /** |
||
161 | * @param mixed $criteria |
||
162 | * @return EntityInterface|null |
||
163 | */ |
||
164 | public function find($criteria) |
||
184 | |||
185 | /** |
||
186 | * @param mixed $id |
||
187 | * @return EntityInterface|null |
||
188 | */ |
||
189 | public function findById($id) |
||
196 | |||
197 | /** |
||
198 | * @param mixed $criteria |
||
199 | * @return EntityInterface[] |
||
200 | */ |
||
201 | public function findMany($criteria) |
||
218 | |||
219 | /** |
||
220 | * @param mixed $criteria |
||
221 | * @return int |
||
222 | */ |
||
223 | public function count($criteria) |
||
242 | |||
243 | /** |
||
244 | * @param array $filter |
||
245 | * @return CriteriaInterface |
||
246 | */ |
||
247 | public function createCriteria(array $filter = []) |
||
251 | |||
252 | /** |
||
253 | * @param EntityInterface $entity |
||
254 | */ |
||
255 | protected function toIdentityMap(EntityInterface $entity) |
||
260 | |||
261 | /** |
||
262 | * @param EntityInterface $changedEntity |
||
263 | * @return bool |
||
264 | */ |
||
265 | protected function isEntityChanged(EntityInterface $changedEntity) |
||
270 | |||
271 | /** |
||
272 | * @return EntityChangedEvent |
||
273 | */ |
||
274 | protected function getEvent() |
||
283 | |||
284 | /** |
||
285 | * @param EntityInterface $createdEntity |
||
286 | */ |
||
287 | protected function triggerCreate(EntityInterface&$createdEntity) |
||
302 | |||
303 | /** |
||
304 | * @param EntityInterface $deletedEntity |
||
305 | */ |
||
306 | protected function triggerDelete(EntityInterface $deletedEntity) |
||
317 | |||
318 | /** |
||
319 | * @param EntityChangedEvent $e |
||
320 | */ |
||
321 | protected function triggerChanges(EntityChangedEvent $e) |
||
326 | |||
327 | /** |
||
328 | * @param EntityChangedEvent $e |
||
329 | */ |
||
330 | protected function triggerPreChanges(EntityChangedEvent $e) |
||
335 | |||
336 | /** |
||
337 | * @param EntityChangedEvent $e |
||
338 | */ |
||
339 | protected function triggerAttributesChange(EntityChangedEvent $e) |
||
350 | |||
351 | /** |
||
352 | * @param EntityInterface $changedEntity |
||
353 | * @return string |
||
354 | */ |
||
355 | protected function getEntityChangeEventName(EntityInterface $changedEntity) |
||
359 | |||
360 | /** |
||
361 | * @param EntityInterface $changedEntity |
||
362 | * @param $attributeName |
||
363 | * @return string |
||
364 | */ |
||
365 | protected function getAttributeChangeEventName(EntityInterface $changedEntity, $attributeName) |
||
369 | } |
||
370 |