protected function findUserBy($key, $value)
{
if (!empty($value)) {
$user = $this->container->get('fos_user.user_manager')->{'findUserBy' . ucfirst($key)}($value);
}
if (empty($user)) {
throw new NotFoundHttpException(sprintf('The user with "%s" does not exist for value "%s"', $key, $value));
}
return $user;
}