Skip to content

Added tokens to the mail template #354

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

Merged
merged 3 commits into from
Jul 31, 2024
Merged
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
4 changes: 4 additions & 0 deletions src/Gateway/MailerGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Terminal42\NotificationCenterBundle\Parcel\Stamp\LanguageConfigStamp;
use Terminal42\NotificationCenterBundle\Parcel\Stamp\Mailer\BackendAttachmentsStamp;
use Terminal42\NotificationCenterBundle\Parcel\Stamp\Mailer\EmailStamp;
use Terminal42\NotificationCenterBundle\Parcel\Stamp\TokenCollectionStamp;
use Terminal42\NotificationCenterBundle\Receipt\Receipt;

class MailerGateway extends AbstractGateway
Expand Down Expand Up @@ -192,6 +193,7 @@ private function createEmail(Parcel $parcel): Email
private function renderEmailTemplate(Parcel $parcel): string
{
$languageConfig = $parcel->getStamp(LanguageConfigStamp::class)->languageConfig;
$tokenCollection = $parcel->getStamp(TokenCollectionStamp::class)?->tokenCollection;

$this->contaoFramework->initialize();

Expand All @@ -201,6 +203,8 @@ private function renderEmailTemplate(Parcel $parcel): string
$template->css = '';
$template->body = $this->replaceTokensAndInsertTags($parcel, StringUtil::restoreBasicEntities($languageConfig->getString('email_html')));
$template->language = LocaleUtil::formatAsLanguageTag($languageConfig->getString('language'));
$template->parsedTokens = null === $tokenCollection ? [] : $tokenCollection->forSimpleTokenParser();
$template->rawTokens = $tokenCollection;

return $this->contaoFramework->getAdapter(Controller::class)->convertRelativeUrls($this->replaceInsertTags($template->parse()));
}
Expand Down
Loading