Skip to content

Commit

Permalink
Create plain text from template if not already set
Browse files Browse the repository at this point in the history
  • Loading branch information
pjeby committed Apr 5, 2019
1 parent c202951 commit 9feb856
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions EventListener/EmailSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() );
}
}
}

0 comments on commit 9feb856

Please sign in to comment.