public function confirmAction(Request $request, $token)
    {
        $userManager = $this->getUserManager();

        $user = $userManager->findUserByConfirmationToken($token);

        if (null === $user) {
            throw new NotFoundHttpException(sprintf('The user with confirmation token "%s" does not exist', $token));
        }

        $dispatcher = $this->getDispatcher();

        $user->setConfirmationToken(null);
        $user->setEnabled(true);

        $event = new GetResponseUserEvent($user, $request);
        $dispatcher->dispatch(Events::REGISTRATION_CONFIRM, $event);

        $userManager->updateUser($user);

        $response = $event->getResponse();
        if (null === $response) {
            $response = $this->redirect('silex_user.registration_confirmed');
        }
        
        $dispatcher->dispatch(Events::REGISTRATION_CONFIRMED, new FilterUserResponseEvent($user, $request, $response));

        return $response;
    }