]>
Commit | Line | Data |
---|---|---|
0f0e8eb8 JB |
1 | <?php |
2 | ||
3 | namespace Wallabag\UserBundle\EventListener; | |
4 | ||
0f0e8eb8 | 5 | use FOS\UserBundle\Event\FormEvent; |
f808b016 | 6 | use FOS\UserBundle\FOSUserEvents; |
0f0e8eb8 JB |
7 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
8 | use Symfony\Component\HttpFoundation\RedirectResponse; | |
9 | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | |
10 | ||
11 | /** | |
23afdf3a | 12 | * Listener responsible to change the redirection at the end of the password resetting. |
0f0e8eb8 JB |
13 | * |
14 | * @see http://symfony.com/doc/current/bundles/FOSUserBundle/controller_events.html | |
15 | */ | |
16 | class PasswordResettingListener implements EventSubscriberInterface | |
17 | { | |
18 | private $router; | |
19 | ||
20 | public function __construct(UrlGeneratorInterface $router) | |
21 | { | |
22 | $this->router = $router; | |
23 | } | |
24 | ||
25 | /** | |
23afdf3a | 26 | * {@inheritdoc} |
0f0e8eb8 JB |
27 | */ |
28 | public static function getSubscribedEvents() | |
29 | { | |
4094ea47 | 30 | return [ |
0f0e8eb8 | 31 | FOSUserEvents::RESETTING_RESET_SUCCESS => 'onPasswordResettingSuccess', |
4094ea47 | 32 | ]; |
0f0e8eb8 JB |
33 | } |
34 | ||
35 | public function onPasswordResettingSuccess(FormEvent $event) | |
36 | { | |
37 | $url = $this->router->generate('homepage'); | |
38 | ||
39 | $event->setResponse(new RedirectResponse($url)); | |
40 | } | |
41 | } |