@@ 79-99 (lines=21) @@ | ||
76 | * |
|
77 | * @return EntityCollectionInterface|EntityInterface[] |
|
78 | */ |
|
79 | public function load(EntityInterface $entity) |
|
80 | { |
|
81 | $repository = $this->getParentRepository(); |
|
82 | ||
83 | $query = $repository->find() |
|
84 | ->where($this->getConditions($entity)) |
|
85 | ->limit($this->limit); |
|
86 | $this->addJoinTable($query); |
|
87 | $this->checkConditions($query) |
|
88 | ->checkOrder($query); |
|
89 | ||
90 | /** @var EntityCollectionInterface $collection */ |
|
91 | $collection = $query->all(); |
|
92 | ||
93 | $collection |
|
94 | ->setParentEntity($entity) |
|
95 | ->getEmitter() |
|
96 | ->addListener(EntityAdded::ACTION_ADD, [$this, 'add']); |
|
97 | ||
98 | return $collection; |
|
99 | } |
|
100 | ||
101 | /** |
|
102 | * Saves the relation row upon entity add |
@@ 77-96 (lines=20) @@ | ||
74 | * |
|
75 | * @return null|EntityInterface|EntityCollection|EntityInterface[] |
|
76 | */ |
|
77 | public function load(EntityInterface $entity) |
|
78 | { |
|
79 | $repository = $this->getParentRepository(); |
|
80 | ||
81 | $query = $repository->find() |
|
82 | ->where($this->getConditions($entity)) |
|
83 | ->limit($this->limit); |
|
84 | $this->checkConditions($query) |
|
85 | ->checkOrder($query); |
|
86 | ||
87 | /** @var EntityCollectionInterface $collection */ |
|
88 | $collection = $query->all(); |
|
89 | ||
90 | $collection |
|
91 | ->setParentEntity($entity) |
|
92 | ->getEmitter() |
|
93 | ->addListener(EntityAdded::ACTION_ADD, [$this, 'add']); |
|
94 | ||
95 | return $collection; |
|
96 | } |
|
97 | ||
98 | /** |
|
99 | * Saves the relation foreign key upon entity add |