<?php
namespace Aqarmap\Bundle\UserBundle\EventListener;
use Aqarmap\Bundle\NotificationBundle\Types\UserPasswordReset;
use FOS\UserBundle\Event\FilterUserResponseEvent;
use FOS\UserBundle\FOSUserEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
class ResetPasswordListener implements EventSubscriberInterface
{
/**
* @var EventDispatcherInterface
*/
private $eventDispatcher;
/**
* UserManager constructor.
*/
public function __construct(EventDispatcherInterface $eventDispatcher)
{
$this->eventDispatcher = $eventDispatcher;
}
public static function getSubscribedEvents()
{
return [
FOSUserEvents::RESETTING_RESET_COMPLETED => 'passwordResetCompleted',
];
}
public function passwordResetCompleted(FilterUserResponseEvent $event): void
{
$event = (new UserPasswordReset())->setSubject($event->getUser());
$this->eventDispatcher->dispatch($event, 'user.password.reset');
}
}