From 502652996083080efd1e6dc49a08204016424996 Mon Sep 17 00:00:00 2001 From: Yanick Witschi Date: Wed, 31 Jul 2024 08:59:37 +0200 Subject: [PATCH] Added tokens to the mail template (#354) --- src/Gateway/MailerGateway.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Gateway/MailerGateway.php b/src/Gateway/MailerGateway.php index 7d92172..2b6c423 100644 --- a/src/Gateway/MailerGateway.php +++ b/src/Gateway/MailerGateway.php @@ -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 @@ -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(); @@ -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())); }