mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-11-23 04:17:45 +00:00
Ajouter une variable de localisation aux utilisateurs
This commit is contained in:
@@ -16,11 +16,13 @@ use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
||||
use Symfony\Component\Mailer\MailerInterface;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
||||
// use Symfony\Component\Translation\LocaleSwitcher;
|
||||
|
||||
class RecoverPasswordHelper
|
||||
{
|
||||
final public const RECOVER_PASSWORD_ROUTE = 'password_recover';
|
||||
|
||||
public function __construct(private readonly TokenManager $tokenManager, private readonly UrlGeneratorInterface $urlGenerator, private readonly MailerInterface $mailer) {}
|
||||
public function __construct(private readonly TokenManager $tokenManager, private readonly UrlGeneratorInterface $urlGenerator, private readonly MailerInterface $mailer/* , private readonly LocaleSwitcher $localeSwitcher */) {}
|
||||
|
||||
/**
|
||||
* @param bool $absolute
|
||||
@@ -53,6 +55,24 @@ class RecoverPasswordHelper
|
||||
throw new \UnexpectedValueException('No emaail associated to the user');
|
||||
}
|
||||
|
||||
// Implementation with LocaleSwitcher (commented out - to be activated after migration to sf7.2):
|
||||
/*
|
||||
$this->localeSwitcher->runWithLocale($user->getLocale(), function () use ($user, $expiration, $template, $templateParameters, $emailSubject, $additionalUrlParameters) {
|
||||
$email = (new TemplatedEmail())
|
||||
->subject($emailSubject)
|
||||
->to($user->getEmail())
|
||||
->textTemplate($template)
|
||||
->context([
|
||||
'user' => $user,
|
||||
'url' => $this->generateUrl($user, $expiration, true, $additionalUrlParameters),
|
||||
...$templateParameters,
|
||||
]);
|
||||
|
||||
$this->mailer->send($email);
|
||||
});
|
||||
*/
|
||||
|
||||
// Current implementation:
|
||||
$email = (new TemplatedEmail())
|
||||
->subject($emailSubject)
|
||||
->to($user->getEmail())
|
||||
|
||||
Reference in New Issue
Block a user