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

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

        if (null !== $entity->getTenant()) {
            return;
        }

        $tenant = $this->container->get(TenantService::class)->getContext();
        $entity->setTenant($tenant);
    }
public function prePersist(LifecycleEventArgs $args)
    {
        $entity = $args->getEntity();

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

        if (null !== $entity->getTenant()) {
            return;
        }

        $tenant = $this->container->get(TenantService::class)->getContext();
        $entity->setTenant($tenant);
    }
Assign the tenant uuid before persisting the entity, if none provided

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