<?php
declare(strict_types=1);
namespace Harmonizely\EventListener;
use FOS\UserBundle\Event\GetResponseUserEvent;
use FOS\UserBundle\FOSUserEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\RouterInterface;
final class RegistrationConfirmListener implements EventSubscriberInterface
{
private $router;
public function __construct(RouterInterface $router)
{
$this->router = $router;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents()
{
return [
FOSUserEvents::REGISTRATION_CONFIRM => 'onRegistrationConfirm',
];
}
public function onRegistrationConfirm(GetResponseUserEvent $event)
{
$url = $this->router->generate('dashboard_index');
$event->setResponse(new RedirectResponse($url));
}
}