diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-01-21 16:39:13 +0100 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-01-21 16:39:13 +0100 |
commit | 0f0e8eb82a3374e20453fb1f8046325ee306b036 (patch) | |
tree | 4570046b6aa6b29c5ac0fd9289b433d80e69c207 /src/Wallabag/UserBundle/EventListener | |
parent | a0d6ccc5ca0dc0082467cc65b006150aff2488c4 (diff) | |
download | wallabag-0f0e8eb82a3374e20453fb1f8046325ee306b036.tar.gz wallabag-0f0e8eb82a3374e20453fb1f8046325ee306b036.tar.zst wallabag-0f0e8eb82a3374e20453fb1f8046325ee306b036.zip |
Use FOSUserEvents instead of c/p a controller
The `resetAction` was overriden to redirect user to the homepage instead of `fos_user_profile_show`.
Instead of copying the whole method we can simply use FOSUserEvents to handle that.
Diffstat (limited to 'src/Wallabag/UserBundle/EventListener')
-rw-r--r-- | src/Wallabag/UserBundle/EventListener/PasswordResettingListener.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/Wallabag/UserBundle/EventListener/PasswordResettingListener.php b/src/Wallabag/UserBundle/EventListener/PasswordResettingListener.php new file mode 100644 index 00000000..2fdcb441 --- /dev/null +++ b/src/Wallabag/UserBundle/EventListener/PasswordResettingListener.php | |||
@@ -0,0 +1,41 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\UserBundle\EventListener; | ||
4 | |||
5 | use FOS\UserBundle\FOSUserEvents; | ||
6 | use FOS\UserBundle\Event\FormEvent; | ||
7 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
8 | use Symfony\Component\HttpFoundation\RedirectResponse; | ||
9 | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | ||
10 | |||
11 | /** | ||
12 | * Listener responsible to change the redirection at the end of the password resetting | ||
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 | /** | ||
26 | * {@inheritDoc} | ||
27 | */ | ||
28 | public static function getSubscribedEvents() | ||
29 | { | ||
30 | return array( | ||
31 | FOSUserEvents::RESETTING_RESET_SUCCESS => 'onPasswordResettingSuccess', | ||
32 | ); | ||
33 | } | ||
34 | |||
35 | public function onPasswordResettingSuccess(FormEvent $event) | ||
36 | { | ||
37 | $url = $this->router->generate('homepage'); | ||
38 | |||
39 | $event->setResponse(new RedirectResponse($url)); | ||
40 | } | ||
41 | } | ||