src/Entity/EventListener/UuidentifiableListener.php
public function prePersist(LifecycleEventArgs $args)
    {
        $entity = $args->getEntity();

        if (!$entity instanceof Uuidentifiable) {
            return;
        }

        $this->idService->generateUuid($entity);
    }
public function prePersist(LifecycleEventArgs $args)
    {
        $entity = $args->getEntity();

        if (!$entity instanceof Uuidentifiable) {
            return;
        }

        $this->idService->generateUuid($entity);
    }
Generate an uuid before persisting the entity, if none provided

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