mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-12-31 14:31:25 +00:00
Implement LocaleSwitcher in commented block - ready for when we migrate to symfony 7.2
This commit is contained in:
@@ -21,6 +21,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\Mailer\MailerInterface;
|
||||
use Symfony\Component\Workflow\Event\Event;
|
||||
use Symfony\Component\Workflow\Registry;
|
||||
// use Symfony\Component\Translation\LocaleSwitcher;
|
||||
|
||||
final readonly class NotificationToUserGroupsOnTransition implements EventSubscriberInterface
|
||||
{
|
||||
@@ -31,6 +32,7 @@ final readonly class NotificationToUserGroupsOnTransition implements EventSubscr
|
||||
private MailerInterface $mailer,
|
||||
private EntityManagerInterface $entityManager,
|
||||
private EntityWorkflowManager $entityWorkflowManager,
|
||||
// private LocaleSwitcher $localeSwitcher,
|
||||
) {}
|
||||
|
||||
public static function getSubscribedEvents(): array
|
||||
@@ -87,6 +89,24 @@ final readonly class NotificationToUserGroupsOnTransition implements EventSubscr
|
||||
'title' => $title,
|
||||
];
|
||||
|
||||
// Implementation with LocaleSwitcher (commented out - to be activated after migration to sf7.2):
|
||||
// Note: This sends emails to user groups, not individual users, so locale switching may use default locale
|
||||
/*
|
||||
$this->localeSwitcher->runWithLocale('fr', function () use ($context, $userGroup) {
|
||||
$email = new TemplatedEmail();
|
||||
$email
|
||||
->htmlTemplate('@ChillMain/Workflow/workflow_notification_on_transition_completed_content_to_user_group.fr.txt.twig')
|
||||
->context($context)
|
||||
->subject(
|
||||
$this->engine->render('@ChillMain/Workflow/workflow_notification_on_transition_completed_title.fr.txt.twig', $context)
|
||||
)
|
||||
->to($userGroup->getEmail());
|
||||
|
||||
$this->mailer->send($email);
|
||||
});
|
||||
*/
|
||||
|
||||
// Current implementation:
|
||||
$email = new TemplatedEmail();
|
||||
$email
|
||||
->htmlTemplate('@ChillMain/Workflow/workflow_notification_on_transition_completed_content_to_user_group.fr.txt.twig')
|
||||
|
||||
Reference in New Issue
Block a user