Skip to content

Commit

Permalink
Merge pull request #178 from roodjong/custom-mail
Browse files Browse the repository at this point in the history
Support custom support member welcome template
  • Loading branch information
Nowa-Ammerlaan authored May 19, 2024
2 parents da27438 + 9727ec1 commit be5cd69
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ docker compose -f docker/prod/docker-compose.yml --env-file .env.local up --buil

### 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

Expand Down
14 changes: 10 additions & 4 deletions src/Controller/SupportMemberController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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->getLocale() . '.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->getLocale() . '.txt.twig', ['supportMember' => $supportMember])
);
$mailer->send($message);

Expand Down

0 comments on commit be5cd69

Please sign in to comment.