fetchAssociations example

// always add the criteria fields to the collection, otherwise we have conflicts between criteria.fields and criteria.association logic         $fields = $this->addAssociationFieldsToCriteria($criteria$definition$fields);

        if ($definition->isInheritanceAware() && $criteria->hasAssociation('parent')) {
            throw new ParentAssociationCanNotBeFetched();
        }

        $rows = $this->fetch($criteria$definition$context$fields$partial);

        $collection = $this->hydrator->hydrate($collection$definition->getEntityClass()$definition$rows$definition->getEntityName()$context$partial);

        $collection = $this->fetchAssociations($criteria$definition$context$collection$fields$partial);

        $hasIds = !empty($criteria->getIds());
        if ($hasIds && empty($criteria->getSorting())) {
            $collection->sortByIdArray($criteria->getIds());
        }

        return $collection;
    }

    /** * @param array<string, mixed> $partial */
Home | Imprint | This part of the site doesn't use cookies.