/**
  * @return string a unique token
  */
 protected function getUniqueToken()
 {
     $token = $this->tokenGenerator->generateToken();
     try {
         $user = $this->userRepository->findUserByToken($token);
         if (!$user) {
             return $token;
         }
     } catch (NoResultException $ex) {
         return $token;
     }
     return $this->getUniqueToken();
 }
 /**
  * @return string a unique token
  */
 protected function getUniqueToken()
 {
     $token = $this->tokenGenerator->generateToken();
     $user = $this->userRepository->findOneBy(['confirmationKey' => $token]);
     if (!$user) {
         return $token;
     }
     return $this->getUniqueToken();
 }