FOS\UserBundle\Controller\UserController::findUserBy PHP Method

findUserBy() protected method

Find a user by a specific property
protected findUserBy ( string $key, mixed $value ) : User
$key string property name
$value mixed property value
return User
    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;
    }