/** * Attempts to load a user by its activation key and username. * * @param string $activationKey * @param string $username * * @return User */ private function findUserByActivationKeyAndUsername($activationKey, $username) { if (!($user = $this->userRepository->findUserByUsernameAndActivationKey($username, $activationKey))) { throw $this->createActivationException(); } elseif ($this->isActivationExpired($user)) { $this->entityManager->remove($user); $this->entityManager->flush($user); throw $this->createActivationException(); } return $user; }