public function registerAction()
 {
     $user = $this->container->get('security.context')->getToken()->getUser();
     if ($user instanceof UserInterface && 'POST' === $this->container->get('request')->getMethod()) {
         $this->container->get('session')->getFlashBag()->set('sonata_user_error', 'sonata_user_already_authenticated');
         $url = $this->container->get('router')->generate('sonata_user_profile_show');
         return new RedirectResponse($url);
     }
     $form = $this->container->get('fos_user.registration.form');
     $formHandler = $this->container->get('fos_user.registration.form.handler');
     $confirmationEnabled = $this->container->getParameter('fos_user.registration.confirmation.enabled');
     $process = $formHandler->process($confirmationEnabled);
     if ($process) {
         $user = $form->getData();
         // nouveau mail event
         $event = new MailEvent();
         $event->setUserName("{$user}");
         $dispatcher = $this->container->get('event_dispatcher');
         $dispatcher->dispatch(ApplicationEvents::AFTER_REGISTER, $event);
         $route = $this->container->get('session')->get('sonata_basket_delivery_redirect', 'fos_user_security_login');
         $this->container->get('session')->remove('sonata_basket_delivery_redirect');
         $this->setFlash('fos_user_success', 'registration.admin_mail');
         $url = $this->container->get('router')->generate($route);
         $response = new RedirectResponse($url);
         /*
         if ($authUser) {
             $this->authenticateUser($user, $response);
         }
         */
         return $response;
     }
     $this->container->get('session')->set('sonata_user_redirect_url', $this->container->get('request')->headers->get('referer'));
     return $this->container->get('templating')->renderResponse('FOSUserBundle:Registration:register.html.' . $this->getEngine(), array('form' => $form->createView()));
 }
Ejemplo n.º 2
0
 public function sentMailAfterRegister(MailEvent $event)
 {
     $userName = $event->getUserName();
     $body = $this->renderRegisterTemplate($userName);
     $message = \Swift_Message::newInstance()->setSubject('Compte de l\'utilisateur ' . $userName . ' crée, en attente d\'etre dévèrouillé')->setFrom('*****@*****.**')->setTo('*****@*****.**')->setBody($body);
     $this->mailer->send($message);
 }
Ejemplo n.º 3
0
 public function postulateAction($base, $campaign, $matchId)
 {
     $user = $this->container->get('security.context')->getToken()->getUser();
     // nouveau mail event
     $event = new MailEvent();
     $event->setUserName("{$user}");
     $event->setBase("{$base}");
     $event->setCampaign("{$campaign}");
     $event->setMatchingId("{$matchId}");
     $dispatcher = $this->container->get('event_dispatcher');
     $dispatcher->dispatch(ApplicationEvents::AFTER_POSTULATE, $event);
     $this->setFlash('sonata_user_success', 'postulate_sent');
     return $this->redirect($this->generateUrl('match_list'));
 }