<?php
namespace Bidcoz\Bundle\UserBundle\EventListener;
use FOS\UserBundle\Event\FormEvent;
use FOS\UserBundle\FOSUserEvents;
use RS\DiExtraBundle\Annotation as DI;
use Symfony\Bundle\FrameworkBundle\Routing\Router;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
* @DI\Service
*/
class ProfileEditListener
{
private $router;
/**
* @DI\InjectParams({
* "router" = @DI\Inject("router"),
* })
*/
public function __construct(Router $router)
{
$this->router = $router;
}
/**
* @DI\Observe(FOSUserEvents::PROFILE_EDIT_SUCCESS)
*/
public function onProfileEditSuccess(FormEvent $event)
{
$url = $this->router->generate('fos_user_profile_edit');
$event->setResponse(new RedirectResponse($url));
}
}