Task/Doctrine/DoctrineWriterTask.php
protected function writeEntity(ProcessState $state)
    {
        $options = $this->getOptions($state);
        $entity = $state->getInput();

        if (null === $entity) {
            throw new \RuntimeException('DoctrineWriterTask does not allow null input');
        }
        $class = ClassUtils::getClass($entity);
        $entityManager = $this->doctrine->getManagerForClass($class);
        if (!$entityManager instanceof EntityManagerInterface) {
            throw new \UnexpectedValueException("No manager found for class {$class}");
        }
        $entityManager->persist($entity);

        if ($options['global_flush']) {
            $entityManager->flush();
        } else {
            if (!$entityManager instanceof EntityManager) {
                throw new \UnexpectedValueException("Manager for class {$class} does not support unitary flush");
            }
            $entityManager->flush($entity);
        }

        return $entity;
    }
protected function writeEntity(ProcessState $state)
    {
        $options = $this->getOptions($state);
        $entity = $state->getInput();

        if (null === $entity) {
            throw new \RuntimeException('DoctrineWriterTask does not allow null input');
        }
        $class = ClassUtils::getClass($entity);
        $entityManager = $this->doctrine->getManagerForClass($class);
        if (!$entityManager instanceof EntityManagerInterface) {
            throw new \UnexpectedValueException("No manager found for class {$class}");
        }
        $entityManager->persist($entity);

        if ($options['global_flush']) {
            $entityManager->flush();
        } else {
            if (!$entityManager instanceof EntityManager) {
                throw new \UnexpectedValueException("Manager for class {$class} does not support unitary flush");
            }
            $entityManager->flush($entity);
        }

        return $entity;
    }
@param ProcessState $state

@throws \Symfony\Component\OptionsResolver\Exception\ExceptionInterface
@throws \Doctrine\ORM\ORMException

@return mixed