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 CriteriaInterface|array $criteria |
||
162 | * @return EntityInterface|null |
||
163 | */ |
||
164 | public function find($criteria) |
||
188 | |||
189 | /** |
||
190 | * @param mixed $id |
||
191 | * @return EntityInterface|null |
||
192 | */ |
||
193 | public function findById($id) |
||
200 | |||
201 | /** |
||
202 | * @param CriteriaInterface|array $criteria |
||
203 | * @return EntityInterface[] |
||
204 | */ |
||
205 | public function findMany($criteria) |
||
226 | |||
227 | /** |
||
228 | * @param CriteriaInterface|array $criteria |
||
229 | * @return int |
||
230 | */ |
||
231 | public function count($criteria) |
||
254 | |||
255 | /** |
||
256 | * @param array $filter |
||
257 | * @return CriteriaInterface |
||
258 | */ |
||
259 | public function createCriteria(array $filter = []) |
||
263 | |||
264 | /** |
||
265 | * @param EntityInterface $entity |
||
266 | */ |
||
267 | protected function toIdentityMap(EntityInterface $entity) |
||
272 | |||
273 | /** |
||
274 | * @param EntityInterface $changedEntity |
||
275 | * @return bool |
||
276 | */ |
||
277 | protected function isEntityChanged(EntityInterface $changedEntity) |
||
282 | |||
283 | /** |
||
284 | * @return EntityChangedEvent |
||
285 | */ |
||
286 | protected function getEvent() |
||
295 | |||
296 | /** |
||
297 | * @param EntityInterface $createdEntity |
||
298 | */ |
||
299 | protected function triggerCreate(EntityInterface&$createdEntity) |
||
314 | |||
315 | /** |
||
316 | * @param EntityInterface $deletedEntity |
||
317 | */ |
||
318 | protected function triggerDelete(EntityInterface $deletedEntity) |
||
329 | |||
330 | /** |
||
331 | * @param EntityChangedEvent $e |
||
332 | */ |
||
333 | protected function triggerChanges(EntityChangedEvent $e) |
||
338 | |||
339 | /** |
||
340 | * @param EntityChangedEvent $e |
||
341 | */ |
||
342 | protected function triggerPreChanges(EntityChangedEvent $e) |
||
347 | |||
348 | /** |
||
349 | * @param EntityChangedEvent $e |
||
350 | */ |
||
351 | protected function triggerAttributesChange(EntityChangedEvent $e) |
||
362 | |||
363 | /** |
||
364 | * @param EntityInterface $changedEntity |
||
365 | * @return string |
||
366 | */ |
||
367 | protected function getEntityChangeEventName(EntityInterface $changedEntity) |
||
371 | |||
372 | /** |
||
373 | * @param EntityInterface $changedEntity |
||
374 | * @param $attributeName |
||
375 | * @return string |
||
376 | */ |
||
377 | protected function getAttributeChangeEventName(EntityInterface $changedEntity, $attributeName) |
||
381 | } |
||
382 |