Skip to content

Commit

Permalink
Added tokens to the mail template (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
Toflar authored Jul 31, 2024
1 parent b430c4b commit 5026529
Showing 1 changed file with 4 additions and 0 deletions.
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

0 comments on commit 5026529

Please sign in to comment.