backports murph-skeleton

This commit is contained in:
Simon Vieille 2021-03-24 17:21:03 +01:00
parent 1b2707585a
commit 5d2ae5ffb6

View file

@ -8,6 +8,7 @@ use App\Core\Notification\MailNotifier;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface; use Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
/** /**
* class EventListener. * class EventListener.
@ -20,17 +21,20 @@ class PasswordRequestEventSubscriber implements EventSubscriberInterface
protected UrlGeneratorInterface $urlGenerator; protected UrlGeneratorInterface $urlGenerator;
protected EntityManager $entityManager; protected EntityManager $entityManager;
protected TokenGeneratorInterface $tokenGenerator; protected TokenGeneratorInterface $tokenGenerator;
protected TranslatorInterface $translator;
public function __construct( public function __construct(
MailNotifier $notifier, MailNotifier $notifier,
UrlGeneratorInterface $urlGenerator, UrlGeneratorInterface $urlGenerator,
EntityManager $entityManager, EntityManager $entityManager,
TokenGeneratorInterface $tokenGenerator TokenGeneratorInterface $tokenGenerator,
TranslatorInterface $translator
) { ) {
$this->notifier = $notifier; $this->notifier = $notifier;
$this->urlGenerator = $urlGenerator; $this->urlGenerator = $urlGenerator;
$this->entityManager = $entityManager; $this->entityManager = $entityManager;
$this->tokenGenerator = $tokenGenerator; $this->tokenGenerator = $tokenGenerator;
$this->translator = $translator;
} }
public static function getSubscribedEvents() public static function getSubscribedEvents()
@ -49,7 +53,7 @@ class PasswordRequestEventSubscriber implements EventSubscriberInterface
$this->entityManager->update($user); $this->entityManager->update($user);
$this->notifier $this->notifier
->setSubject('Mot de passe perdu') ->setSubject($translator->trans('Mot de passe perdu'))
->addRecipient($user->getEmail()) ->addRecipient($user->getEmail())
->notify('@Core/mail/account/resetting_request.html.twig', [ ->notify('@Core/mail/account/resetting_request.html.twig', [
'reseting_update_link' => $this->urlGenerator->generate( 'reseting_update_link' => $this->urlGenerator->generate(