code: public function preFlush(PreFlushEventArgs $args)
      {
          $entities = $args->getEntityManager()->getUnitOfWork()->getScheduledEntityInsertions();
  
          foreach ($entities as $entity) {
              if (!$entity instanceof Config) {
                  continue;
              }
  
              $key = $entity->getKey();
              $encrypt = $this->configCollection->get($key)['encrypt'];
              $entity->setEncrypt($encrypt);
          }
      }
docs: Set config entity encrypt property before saving in storage.
  
  @param \Doctrine\ORM\Event\PreFlushEventArgs $args