src/EventListener/PasswordResettingListener.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use FOS\UserBundle\FOSUserEvents;
  4. use FOS\UserBundle\Event\FormEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. use Symfony\Component\HttpFoundation\RedirectResponse;
  7. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  8. /**
  9.  * Listener responsible to change the redirection at the end of the password resetting
  10.  */
  11. class PasswordResettingListener implements EventSubscriberInterface {
  12.     private $router;
  13.     public function __construct(UrlGeneratorInterface $router) {
  14.         $this->router $router;
  15.     }
  16.     public static function getSubscribedEvents() {
  17.         return [
  18.             FOSUserEvents::CHANGE_PASSWORD_SUCCESS => 'onPasswordResettingSuccess',
  19.         ];
  20.     }
  21.     public function onPasswordResettingSuccess(FormEvent $event) {
  22.         $url $this->router->generate('nomogram_index');
  23.         $event->setResponse(new RedirectResponse($url));
  24.     }
  25. }