code: 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);
      }
docs: Assign the tenant uuid before persisting the entity, if none provided
  
  @param \Doctrine\ORM\Event\LifecycleEventArgs $args