Skip to content

Commit

Permalink
Support custom support member welcome template
Browse files Browse the repository at this point in the history
Mirrors the changes from #169

Closes: #170
Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
  • Loading branch information
Nowa-Ammerlaan committed May 19, 2024
1 parent 4ea83f8 commit bb8b075
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions src/Controller/Admin/MembershipApplicationCrud.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down
10 changes: 8 additions & 2 deletions src/Controller/SupportMemberController.php
Original file line number Diff line number Diff line change
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->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);

Expand Down

0 comments on commit bb8b075

Please sign in to comment.