src/Valkyrja/ORM/Repositories/PDORepository.php
protected function getEntityRelations(Entity $entity): Entity
    {
        $propertyTypes  = $entity::getPropertyTypes();
        $propertyMapper = $entity->getPropertyMapper();

        // Iterate through the property types
        foreach ($propertyTypes as $property => $type) {
            $entityName  = \is_array($type) ? $type[0] : $type;
            $propertyMap = $propertyMapper[$property] ?? null;

            if (null !== $propertyMap && (\is_array($type) || ! PropertyType::isValid($type))) {
                $repository   = $this->entityManager->getRepository($entityName);
                $orderBy      = $propertyMap[PropertyMap::ORDER_BY] ?? null;
                $limit        = $propertyMap[PropertyMap::LIMIT] ?? null;
                $offset       = $propertyMap[PropertyMap::OFFSET] ?? null;
                $columns      = $propertyMap[PropertyMap::COLUMNS] ?? null;
                $getRelations = $propertyMap[PropertyMap::GET_RELATIONS] ?? true;

                unset(
                    $propertyMap[PropertyMap::ORDER_BY],
                    $propertyMap[PropertyMap::LIMIT],
                    $propertyMap[PropertyMap::OFFSET],
                    $propertyMap[PropertyMap::COLUMNS],
                    $propertyMap[PropertyMap::GET_RELATIONS]
                );

                $entities = $repository->findBy($propertyMap, $orderBy, $limit, $offset, $columns, $getRelations);

                if (\is_array($type)) {
                    $entity->{$property} = $entities;

                    continue;
                }

                if (empty($entities)) {
                    continue;
                }

                $entity->{$property} = $entities[0];
            }
        }

        return $entity;
    }
protected function getEntityRelations(Entity $entity): Entity
    {
        $propertyTypes  = $entity::getPropertyTypes();
        $propertyMapper = $entity->getPropertyMapper();

        // Iterate through the property types
        foreach ($propertyTypes as $property => $type) {
            $entityName  = \is_array($type) ? $type[0] : $type;
            $propertyMap = $propertyMapper[$property] ?? null;

            if (null !== $propertyMap && (\is_array($type) || ! PropertyType::isValid($type))) {
                $repository   = $this->entityManager->getRepository($entityName);
                $orderBy      = $propertyMap[PropertyMap::ORDER_BY] ?? null;
                $limit        = $propertyMap[PropertyMap::LIMIT] ?? null;
                $offset       = $propertyMap[PropertyMap::OFFSET] ?? null;
                $columns      = $propertyMap[PropertyMap::COLUMNS] ?? null;
                $getRelations = $propertyMap[PropertyMap::GET_RELATIONS] ?? true;

                unset(
                    $propertyMap[PropertyMap::ORDER_BY],
                    $propertyMap[PropertyMap::LIMIT],
                    $propertyMap[PropertyMap::OFFSET],
                    $propertyMap[PropertyMap::COLUMNS],
                    $propertyMap[PropertyMap::GET_RELATIONS]
                );

                $entities = $repository->findBy($propertyMap, $orderBy, $limit, $offset, $columns, $getRelations);

                if (\is_array($type)) {
                    $entity->{$property} = $entities;

                    continue;
                }

                if (empty($entities)) {
                    continue;
                }

                $entity->{$property} = $entities[0];
            }
        }

        return $entity;
    }
Get an entity with all its relations.

@param Entity $entity

@return Entity