private function deduplicateValueObjectInsertions()
    {
        $unitOfWork = $this->entityManager->getUnitOfWork();
        $entityInsertions = $unitOfWork->getScheduledEntityInsertions();

        $knownValueObjects = [];
        foreach ($entityInsertions as $entity) {
            $className = TypeHandling::getTypeForValue($entity);
            if ($this->reflectionService->getClassSchema($className)->getModelType() === ClassSchema::MODELTYPE_VALUEOBJECT) {
                $identifier = $this->persistenceManager->getIdentifierByObject($entity);

                if (isset($knownValueObjects[$className][$identifier]) || $unitOfWork->getEntityPersister($className)->exists($entity)) {
                    unset($entityInsertions[spl_object_hash($entity)]);
                    continue;
                }

                $knownValueObjects[$className][$identifier] = true;
            }
        }

        ObjectAccess::setProperty($unitOfWork, 'entityInsertions', $entityInsertions, true);
    }
private function deduplicateValueObjectInsertions()
    {
        $unitOfWork = $this->entityManager->getUnitOfWork();
        $entityInsertions = $unitOfWork->getScheduledEntityInsertions();

        $knownValueObjects = [];
        foreach ($entityInsertions as $entity) {
            $className = TypeHandling::getTypeForValue($entity);
            if ($this->reflectionService->getClassSchema($className)->getModelType() === ClassSchema::MODELTYPE_VALUEOBJECT) {
                $identifier = $this->persistenceManager->getIdentifierByObject($entity);

                if (isset($knownValueObjects[$className][$identifier]) || $unitOfWork->getEntityPersister($className)->exists($entity)) {
                    unset($entityInsertions[spl_object_hash($entity)]);
                    continue;
                }

                $knownValueObjects[$className][$identifier] = true;
            }
        }

        ObjectAccess::setProperty($unitOfWork, 'entityInsertions', $entityInsertions, true);
    }
private function deduplicateValueObjectInsertions ( ) { $ unitOfWork = $ this -> entityManager -> getUnitOfWork ( ) ; $ entityInsertions = $ unitOfWork -> getScheduledEntityInsertions ( ) ; $ knownValueObjects = [ ] ; foreach ( $ entityInsertions as $ entity ) { $ className = TypeHandling :: getTypeForValue ( $ entity ) ; if ( $ this -> reflectionService -> getClassSchema ( $ className ) -> getModelType ( ) === ClassSchema :: MODELTYPE_VALUEOBJECT ) { $ identifier = $ this -> persistenceManager -> getIdentifierByObject ( $ entity ) ; if ( isset ( $ knownValueObjects [ $ className ] [ $ identifier ] ) || $ unitOfWork -> getEntityPersister ( $ className ) -> exists ( $ entity ) ) { unset ( $ entityInsertions [ spl_object_hash ( $ entity ) ] ) ; continue ; } $ knownValueObjects [ $ className ] [ $ identifier ] = true ; } } ObjectAccess :: setProperty ( $ unitOfWork , 'entityInsertions' , $ entityInsertions , true ) ; }
Loops over scheduled insertions and checks for duplicate value objects. Any duplicates are unset from the
list of scheduled insertions.

@return void
Loops over scheduled insertions and checks for duplicate value objects . Any duplicates are unset from the list of scheduled insertions .