/** * @param Property $property * @param Relationship\BelongsToMany $relationship micro-optimalization * @param Filtering|null $filtering * @return Entity[] */ private function getBelongsToManyValue(Property $property, Relationship\BelongsToMany $relationship, Filtering $filtering = null) { $targetTable = $relationship->getTargetTable(); $rows = $this->row->referencing($targetTable, $relationship->getColumnReferencingSourceTable(), $filtering, $relationship->getStrategy()); $value = []; foreach ($rows as $row) { $entityClass = $this->mapper->getEntityClass($targetTable, $row); $entity = $this->entityFactory->createEntity($entityClass, $row); $this->checkConsistency($property, $entityClass, $entity); $entity->makeAlive($this->entityFactory); $value[] = $entity; } return $this->entityFactory->createCollection($value); }