/**
  * @EXT\Route(
  *     "/publicurl/edit",
  *      name="claro_user_public_url_edit"
  * )
  * @SEC\Secure(roles="ROLE_USER")
  * @EXT\Template()
  * @EXT\ParamConverter("loggedUser", options={"authenticatedUser" = true})
  */
 public function editPublicUrlAction(User $loggedUser)
 {
     $currentPublicUrl = $loggedUser->getPublicUrl();
     $form = $this->createForm(new UserPublicProfileUrlType(), $loggedUser);
     $form->handleRequest($this->request);
     if ($form->isValid()) {
         /** @var \Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface $sessionFlashBag */
         $sessionFlashBag = $this->get('session')->getFlashBag();
         /** @var \Symfony\Component\Translation\TranslatorInterface $translator */
         $translator = $this->get('translator');
         try {
             /** @var \Claroline\CoreBundle\Entity\User $user */
             $user = $form->getData();
             $user->setHasTunedPublicUrl(true);
             $entityManager = $this->get('doctrine.orm.entity_manager');
             $entityManager->persist($user);
             $entityManager->flush();
             $sessionFlashBag->add('success', $translator->trans('tune_public_url_success', array(), 'platform'));
         } catch (\Exception $exception) {
             $sessionFlashBag->add('error', $translator->trans('tune_public_url_error', array(), 'platform'));
         }
         return $this->redirect($this->generateUrl('claro_profile_view'));
     }
     return array('form' => $form->createView(), 'user' => $loggedUser, 'currentPublicUrl' => $currentPublicUrl);
 }
 /**
  * @EXT\Route(
  *     "/send/{userId}",
  *     name="claro_mail_send"
  * )
  * @EXT\ParamConverter(
  *      "user",
  *      class="ClarolineCoreBundle:User",
  *      options={"id" = "userId", "strictId" = true}
  * )
  * @EXT\Template("ClarolineCoreBundle:Mail:form.html.twig")
  *
  * Handles the mail form submission (sends a mail).
  *
  * @param User $user
  *
  * @return Response
  */
 public function sendAction(User $user)
 {
     $mailType = new SendMailType();
     $form = $this->formFactory->create($mailType);
     $form->handleRequest($this->request);
     $sender = $this->tokenStorage->getToken()->getUser();
     if ($form->isValid()) {
         $data = $form->getData();
         $body = $data['content'];
         $this->mailManager->send($data['object'], $body, array($user), $sender);
     }
     return new RedirectResponse($this->router->generate('claro_public_profile_view', array('publicUrl' => $user->getPublicUrl())));
 }