Skip to content

Commit

Permalink
Merge pull request #10 from kuzmany/fix-same-value-campaign-batch
Browse files Browse the repository at this point in the history
Prevent Same value for different contacts + support for subjects
  • Loading branch information
corvis committed Feb 24, 2020
2 parents 510c369 + c3b5cb5 commit ffeff77
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions EventListener/EmailSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public function __construct(TemplateProcessor $templateProcessor)
public static function getSubscribedEvents()
{
return [
EmailEvents::EMAIL_ON_SEND => ['onEmailGenerate', 0],
EmailEvents::EMAIL_ON_DISPLAY => ['onEmailGenerate', 0]
EmailEvents::EMAIL_ON_SEND => ['onEmailGenerate', 300],
EmailEvents::EMAIL_ON_DISPLAY => ['onEmailGenerate', 0],
];
}

Expand All @@ -52,9 +52,22 @@ public static function getSubscribedEvents()
public function onEmailGenerate(Events\EmailSendEvent $event)
{
$this->logger->info('onEmailGenerate MauticAdvancedTemplatesBundle\EmailSubscriber');
$content = $event->getContent();

if ($event->getEmail()) {
$subject = $event->getEmail()->getSubject();
$content = $event->getEmail()->getCustomHtml();
}else{
$subject = $event->getSubject();
$content = $event->getContent();
}

$subject = $this->templateProcessor->processTemplate($subject, $event->getLead());
$event->setSubject($subject);

$content = $this->templateProcessor->processTemplate($content, $event->getLead());
$event->setContent($content);


if ( empty( trim($event->getPlainText()) ) ) {
$event->setPlainText( (new PlainTextHelper($content))->getText() );
}
Expand Down

0 comments on commit ffeff77

Please sign in to comment.