/**
  *
  * @Route("/unsubscribe/{type}/{email}", name="user_unsubscribe")
  * @Template
  */
 public function unsubscribeAction($type, $email)
 {
     $notifType = $this->repo('NotificationType')->find($type);
     if (!$notifType) {
         throw $this->createNotFoundException('Unknown notification type');
     }
     $email = Strings::base64DecodeUrl($email);
     /** @var UserManager $userMgr */
     $userMgr = $this->get('fos_user.user_manager');
     /** @var User $user */
     $user = $userMgr->findUserByEmail($email);
     if (!$user) {
         throw $this->createNotFoundException('Unknown user');
     }
     $sub = NotificationSub::make($user, $notifType);
     if ($oldsub = $user->hasNotificationSub($sub)) {
         $user->removeNotificationSub($oldsub);
         $this->em()->remove($oldsub);
         $this->em()->flush();
     }
     return ['newsletter' => $notifType];
 }
 /**
  * @Route("/register/resend/{email}", name="register_resend")
  */
 public function resendConfirmationAction($email)
 {
     $email = Strings::base64DecodeUrl($email);
     $user = $this->get('fos_user.user_manager')->findUserByEmail($email);
     if ($user === null) {
         throw new NotFoundHttpException(sprintf('The user with email "%s" does not exist', htmlentities($email)));
     }
     $token = $user->getConfirmationToken();
     if (empty($token)) {
         $user->setConfirmationToken($this->get('fos_user.util.token_generator')->generateToken());
         $this->get('fos_user.user_manager')->updateUser($user);
     }
     $this->sendConfirmationEmailMessage($user, null);
     $this->flash('success', 'The confirmation email was re-sent to ' . htmlentities($email));
     $this->get('session')->save();
     return $this->redirectRoute('fos_user_security_login');
     //, ['resent_confirmation' => 1]);
 }