From bb8b075009fcf4299a3434b10edc9a7d76c5645b Mon Sep 17 00:00:00 2001 From: Andrew Ammerlaan Date: Sun, 19 May 2024 15:11:11 +0200 Subject: [PATCH 1/2] Support custom support member welcome template Mirrors the changes from https://github.com/roodjong/mijnrood/pull/169 Closes: https://github.com/roodjong/mijnrood/issues/170 Signed-off-by: Andrew Ammerlaan --- README.md | 8 +++++--- src/Controller/Admin/MembershipApplicationCrud.php | 8 ++++---- src/Controller/SupportMemberController.php | 10 ++++++++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9755018..98b4592 100644 --- a/README.md +++ b/README.md @@ -55,9 +55,11 @@ Look at `src/DataFixtures/` to see an overview of all test data, including other ### Custom welcome mail -To add a custom welcome email, put the two templates (html and plain text) in: - -`templates/custom/email/html/welcome.html.twig` and `templates/custom/email/text/welcome.html.txt` +To add a custom welcome email, put the templates (html and plain text) in `templates/custom/email`. +Supported override templates are: +- `welcome.html.twig`, `welcome.html.txt.twig` +- `welcome_support-en.html.twig`, `welcome_support-en.txt.twig` +- `welcome_support-nl.html.twig`, `welcome_support-nl.txt.twig` ## Contributing diff --git a/src/Controller/Admin/MembershipApplicationCrud.php b/src/Controller/Admin/MembershipApplicationCrud.php index ab478db..372c7c3 100644 --- a/src/Controller/Admin/MembershipApplicationCrud.php +++ b/src/Controller/Admin/MembershipApplicationCrud.php @@ -128,11 +128,11 @@ public function acceptApplication(AdminContext $context) $em->remove($application); $em->flush(); - $templatePrefix = ''; + $templatePrefix = ''; - if (is_dir($this->getParameter('kernel.project_dir') . '/templates/custom')) { - $templatePrefix = 'custom/'; - } + if (is_dir($this->getParameter('kernel.project_dir') . '/templates/custom')) { + $templatePrefix = 'custom/'; + } $message = (new Email()) ->subject("Welkom bij $organizationName!") diff --git a/src/Controller/SupportMemberController.php b/src/Controller/SupportMemberController.php index 53bfede..36d3af3 100644 --- a/src/Controller/SupportMemberController.php +++ b/src/Controller/SupportMemberController.php @@ -216,16 +216,22 @@ public function webhook(Request $request, MailerInterface $mailer, TranslatorInt $em->flush(); $noReplyMail = $this->getParameter('app.noReplyAddress'); + $templatePrefix = ''; + + if (is_dir($this->getParameter('kernel.project_dir') . '/templates/custom')) { + $templatePrefix = 'custom/'; + } + // Send confirmation email $message = (new Email()) ->subject($translator->trans('Welkom als steunlid bij ROOD, Socialistische Jongeren')) ->to(new Address($supportMember->getEmail(), $supportMember->getFirstName() .' '. $supportMember->getLastName())) ->from(new Address($noReplyMail, 'ROOD, Socialistische Jongeren')) ->html( - $this->renderView('email/html/welcome_support-' . $request->locale . '.html.twig', ['supportMember' => $supportMember]) + $this->renderView($templatePrefix . 'email/html/welcome_support-' . $request->locale . '.html.twig', ['supportMember' => $supportMember]) ) ->text( - $this->renderView('email/text/welcome_support-' . $request->locale . '.txt.twig', ['supportMember' => $supportMember]) + $this->renderView($templatePrefix . 'email/text/welcome_support-' . $request->locale . '.txt.twig', ['supportMember' => $supportMember]) ); $mailer->send($message); From 9727ec19ee820969d1f1d6c99f369ae5ec3cae90 Mon Sep 17 00:00:00 2001 From: Jelle Besseling Date: Sun, 19 May 2024 17:26:59 +0200 Subject: [PATCH 2/2] Use getLocale method --- src/Controller/SupportMemberController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Controller/SupportMemberController.php b/src/Controller/SupportMemberController.php index 36d3af3..fea7bab 100644 --- a/src/Controller/SupportMemberController.php +++ b/src/Controller/SupportMemberController.php @@ -124,7 +124,7 @@ public function handleRedirect(Request $request, string $customerId): Response } $retryUrl = $this->generateUrl('support_member_retry', [ - 'customerId' => $customerId, '_locale' => $request->locale + 'customerId' => $customerId, '_locale' => $request->getLocale() ]); return $this->render('user/support_member/failed.html.twig', [ @@ -153,7 +153,7 @@ public function retryPayment(Request $request, string $customerId, TranslatorInt if ($supportMembershipApplication === null) { return $this->redirectToRoute('support_member_redirect', [ - 'customerId' => $customerId, '_locale' => $request->locale + 'customerId' => $customerId, '_locale' => $request->getLocale() ]); } else @@ -228,10 +228,10 @@ public function webhook(Request $request, MailerInterface $mailer, TranslatorInt ->to(new Address($supportMember->getEmail(), $supportMember->getFirstName() .' '. $supportMember->getLastName())) ->from(new Address($noReplyMail, 'ROOD, Socialistische Jongeren')) ->html( - $this->renderView($templatePrefix . 'email/html/welcome_support-' . $request->locale . '.html.twig', ['supportMember' => $supportMember]) + $this->renderView($templatePrefix . 'email/html/welcome_support-' . $request->getLocale() . '.html.twig', ['supportMember' => $supportMember]) ) ->text( - $this->renderView($templatePrefix . 'email/text/welcome_support-' . $request->locale . '.txt.twig', ['supportMember' => $supportMember]) + $this->renderView($templatePrefix . 'email/text/welcome_support-' . $request->getLocale() . '.txt.twig', ['supportMember' => $supportMember]) ); $mailer->send($message);