src/Encryption/EventListener/Entity/Encryptable/PreFlushListener.php
public function preFlush(PreFlushEventArgs $args)
    {
        $entities = $args->getEntityManager()->getUnitOfWork()->getScheduledEntityInsertions();

        foreach ($entities as $entity) {
            if (!$entity instanceof Encryptable) {
                continue;
            }

            $this->encryptionService->encrypt($entity);
        }
    }
public function preFlush(PreFlushEventArgs $args)
    {
        $entities = $args->getEntityManager()->getUnitOfWork()->getScheduledEntityInsertions();

        foreach ($entities as $entity) {
            if (!$entity instanceof Encryptable) {
                continue;
            }

            $this->encryptionService->encrypt($entity);
        }
    }
Encrypt encryptable entity properties before saving in storage.

@param \Doctrine\ORM\Event\PreFlushEventArgs $args