src/AppBundle/EventListener/RegistrationConfirmListener.php line 31

Open in your IDE?
  1. <?php
  2. namespace AppBundle\EventListener;
  3. use FOS\UserBundle\Event\FormEvent;
  4. use FOS\UserBundle\Event\GetResponseUserEvent;
  5. use FOS\UserBundle\FOSUserEvents;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. use Symfony\Component\HttpFoundation\RedirectResponse;
  8. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  9. class RegistrationConfirmListener implements EventSubscriberInterface
  10. {
  11.     private $router;
  12.     public function __construct(UrlGeneratorInterface $router)
  13.     {
  14.         $this->router $router;
  15.     }
  16.     /**
  17.      * {@inheritDoc}
  18.      */
  19.     public static function getSubscribedEvents()
  20.     {
  21.         return array(
  22.             FOSUserEvents::REGISTRATION_SUCCESS => 'onRegistrationConfirm'
  23.         );
  24.     }
  25.     public function onRegistrationConfirm(FormEvent $event)
  26.     {
  27.         $url $this->router->generate('users_index');
  28.         $event->setResponse(new RedirectResponse($url));
  29.     }
  30. }