Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom support member welcome template #178

Merged
merged 2 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading