UserAdminBundle/EventSubscriber/ResetPasswordSubscriber.php
<?php
namespace OpenOrchestra\UserAdminBundle\EventSubscriber;
use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Event\FormEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\RouterInterface;
/**
* Class ResetPasswordSubscriber
*/
class ResetPasswordSubscriber implements EventSubscriberInterface
{
protected $router;
/**
* @param RouterInterface $router
*/
public function __construct(RouterInterface $router)
{
$this->router = $router;
}
/**
* @param FormEvent $event
*/
public function onResettingResetSuccess(FormEvent $event)
{
$url = $this->router->generate('homepage');
$response = new RedirectResponse($url);
$event->setResponse($response);
}
/**
* @return array The event names to listen to
*/
public static function getSubscribedEvents()
{
return array(
FOSUserEvents::RESETTING_RESET_SUCCESS => 'onResettingResetSuccess',
);
}
}