src/AppBundle/EventListener/RegistrationConfirmListener.php line 30

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