From 9feb85674020b6a513d44dea26deacc6f955f4b3 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Fri, 5 Apr 2019 14:54:53 -0400 Subject: [PATCH] Create plain text from template if not already set --- EventListener/EmailSubscriber.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/EventListener/EmailSubscriber.php b/EventListener/EmailSubscriber.php index 2e994f9..85c7040 100644 --- a/EventListener/EmailSubscriber.php +++ b/EventListener/EmailSubscriber.php @@ -5,6 +5,7 @@ use Mautic\CoreBundle\EventListener\CommonSubscriber; use Mautic\EmailBundle\EmailEvents; use Mautic\EmailBundle\Event as Events; +use Mautic\EmailBundle\Helper\PlainTextHelper; use Mautic\CoreBundle\Exception as MauticException; use MauticPlugin\MauticAdvancedTemplatesBundle\Helper\TemplateProcessor; use Psr\Log\LoggerInterface; @@ -54,5 +55,8 @@ public function onEmailGenerate(Events\EmailSendEvent $event) $content = $event->getContent(); $content = $this->templateProcessor->processTemplate($content, $event->getLead()); $event->setContent($content); + if ( empty( trim($event->getPlainText()) ) ) { + $event->setPlainText( (new PlainTextHelper($content))->getText() ); + } } } \ No newline at end of file