src/Entity/Factory/EntityFactory.php
private function convertCollectionOfDtosToEntities(Collection $collection)
    {
        if (0 === $collection->count()) {
            return;
        }
        list($dtoFqn, $collectionEntityFqn) = $this->deriveDtoAndEntityFqnFromCollection($collection);

        foreach ($collection as $key => $dto) {
            if ($dto instanceof $collectionEntityFqn) {
                continue;
            }
            if (false === \is_object($dto)) {
                throw new \InvalidArgumentException('Unexpected DTO value ' .
                                                    \print_r($dto, true) .
                                                    ', expected an instance of' .
                                                    $dtoFqn);
            }
            if (false === ($dto instanceof DataTransferObjectInterface)) {
                throw new \InvalidArgumentException('Found none DTO item in collection, was instance of ' .
                                                    \get_class($dto));
            }
            if (false === ($dto instanceof $dtoFqn)) {
                throw new \InvalidArgumentException('Unexpected DTO ' . \get_class($dto) . ', expected ' . $dtoFqn);
            }
            $collection->set($key, $this->createEntity($collectionEntityFqn, $dto, false));
        }
    }
private function convertCollectionOfDtosToEntities(Collection $collection)
    {
        if (0 === $collection->count()) {
            return;
        }
        list($dtoFqn, $collectionEntityFqn) = $this->deriveDtoAndEntityFqnFromCollection($collection);

        foreach ($collection as $key => $dto) {
            if ($dto instanceof $collectionEntityFqn) {
                continue;
            }
            if (false === \is_object($dto)) {
                throw new \InvalidArgumentException('Unexpected DTO value ' .
                                                    \print_r($dto, true) .
                                                    ', expected an instance of' .
                                                    $dtoFqn);
            }
            if (false === ($dto instanceof DataTransferObjectInterface)) {
                throw new \InvalidArgumentException('Found none DTO item in collection, was instance of ' .
                                                    \get_class($dto));
            }
            if (false === ($dto instanceof $dtoFqn)) {
                throw new \InvalidArgumentException('Unexpected DTO ' . \get_class($dto) . ', expected ' . $dtoFqn);
            }
            $collection->set($key, $this->createEntity($collectionEntityFqn, $dto, false));
        }
    }
private function convertCollectionOfDtosToEntities ( Collection $ collection ) { if ( 0 === $ collection -> count ( ) ) { return ; } list ( $ dtoFqn , $ collectionEntityFqn ) = $ this -> deriveDtoAndEntityFqnFromCollection ( $ collection ) ; foreach ( $ collection as $ key => $ dto ) { if ( $ dto instanceof $ collectionEntityFqn ) { continue ; } if ( false === \ is_object ( $ dto ) ) { throw new \ InvalidArgumentException ( 'Unexpected DTO value ' . \ print_r ( $ dto , true ) . ', expected an instance of' . $ dtoFqn ) ; } if ( false === ( $ dto instanceof DataTransferObjectInterface ) ) { throw new \ InvalidArgumentException ( 'Found none DTO item in collection, was instance of ' . \ get_class ( $ dto ) ) ; } if ( false === ( $ dto instanceof $ dtoFqn ) ) { throw new \ InvalidArgumentException ( 'Unexpected DTO ' . \ get_class ( $ dto ) . ', expected ' . $ dtoFqn ) ; } $ collection -> set ( $ key , $ this -> createEntity ( $ collectionEntityFqn , $ dto , false ) ) ; } }
This will take an ArrayCollection of DTO objects and replace them with the Entities

@param Collection $collection

@throws MultipleValidationException
@throws ValidationException
This will take an ArrayCollection of DTO objects and replace them with the Entities