<?php
namespace AppBundle\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use FOS\UserBundle\FOSUserEvents;
use Symfony\Component\HttpFoundation\RedirectResponse;
use FOS\UserBundle\Event\GetResponseUserEvent;
class RegistrationConfirmListener implements EventSubscriberInterface
{
private $router;
public function __construct(UrlGeneratorInterface $router)
{
$this->router = $router;
}
/**
* {@inheritDoc}
*/
public static function getSubscribedEvents()
{
return [
FOSUserEvents::REGISTRATION_CONFIRM => 'onRegistrationConfirm',
];
}
public function onRegistrationConfirm(GetResponseUserEvent $event)
{
$response = new RedirectResponse($this->router->generate('fos_user_change_password'));
$event->setResponse($response);
}
}