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

Add ability to add custom welcome template #169

Merged
merged 3 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
node_modules
public/assets
public/bundles
docker/mysql
docker/mysql
templates/custom
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ Go to `http://localhost:8080/` and you should be greeted by the MijnRood login p
You can log in with `[email protected]` as email, and `admin` as password.
Look at `src/DataFixtures/` to see an overview of all test data, including other accounts.

## Extra configuration

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

## Contributing

You can generate new migrations with:
Expand Down
10 changes: 8 additions & 2 deletions src/Controller/Admin/MembershipApplicationCrud.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,21 @@ public function acceptApplication(AdminContext $context)
$em->remove($application);
$em->flush();

$templatePrefix = '';

if (is_dir($this->getParameter('kernel.project_dir') . '/templates/custom')) {
$templatePrefix = 'custom/';
}

$message = (new Email())
->subject("Welkom bij $organizationName!")
->to(new Address($member->getEmail(), $member->getFullName()))
->from(new Address($noreply,$organizationName))
->html(
$this->renderView('email/html/welcome.html.twig', ['member' => $member])
$this->renderView($templatePrefix . 'email/html/welcome.html.twig', ['member' => $member])
)
->text(
$this->renderView('email/text/welcome.txt.twig', ['member' => $member])
$this->renderView($templatePrefix . 'email/text/welcome.txt.twig', ['member' => $member])
);
$mailer->send($message);

Expand Down
Loading