src/EventListener/RegistrationConfirmListener.php line 32

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Harmonizely\EventListener;
  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\RouterInterface;
  9. final class RegistrationConfirmListener implements EventSubscriberInterface
  10. {
  11.     private $router;
  12.     public function __construct(RouterInterface $router)
  13.     {
  14.         $this->router $router;
  15.     }
  16.     /**
  17.      * {@inheritdoc}
  18.      */
  19.     public static function getSubscribedEvents()
  20.     {
  21.         return [
  22.             FOSUserEvents::REGISTRATION_CONFIRM => 'onRegistrationConfirm',
  23.         ];
  24.     }
  25.     public function onRegistrationConfirm(GetResponseUserEvent $event)
  26.     {
  27.         $url $this->router->generate('dashboard_index');
  28.         $event->setResponse(new RedirectResponse($url));
  29.     }
  30. }