diff --git a/Classes/EventListener/AddBodyPrefixHeaderAndTextToView.php b/Classes/EventListener/AddBodyPrefixHeaderAndTextToView.php index b9d49f1..8bc0cd4 100644 --- a/Classes/EventListener/AddBodyPrefixHeaderAndTextToView.php +++ b/Classes/EventListener/AddBodyPrefixHeaderAndTextToView.php @@ -26,6 +26,8 @@ public function __invoke(SendMailServiceCreateEmailBodyEvent $event): void if (!$form instanceof FormWithSubmissionLimit) { return; } - $this->powerMailLimitsService->addBodyPrefixHeaderAndTextToView($form, $standaloneView, $email); + + $standaloneView = $this->powerMailLimitsService->getNewViewWithBodyPrefix($form, $standaloneView, $email); + $event->setStandaloneView($standaloneView); } } diff --git a/Classes/EventListener/AddSubjectPrefixToMail.php b/Classes/EventListener/AddSubjectPrefixToMail.php index 716a7f2..65e4d7c 100644 --- a/Classes/EventListener/AddSubjectPrefixToMail.php +++ b/Classes/EventListener/AddSubjectPrefixToMail.php @@ -26,6 +26,7 @@ public function __invoke(SendMailServicePrepareAndSendEvent $event): void return; } - $this->powerMailLimitsService->addSubjectPrefixToMail($form, $message); + $message = $this->powerMailLimitsService->getNewMailMessageWithSubjectPrefix($form, $message); + $event->setMailMessage($message); } } diff --git a/Classes/Service/PowerMailLimitsService.php b/Classes/Service/PowerMailLimitsService.php index 5b3fe2f..9c270f5 100644 --- a/Classes/Service/PowerMailLimitsService.php +++ b/Classes/Service/PowerMailLimitsService.php @@ -11,7 +11,7 @@ class PowerMailLimitsService { const EXTENSION_KEY = 'powermail_limits'; - public function addSubjectPrefixToMail(FormWithSubmissionLimit $form, MailMessage $message): void + public function getNewMailMessageWithSubjectPrefix(FormWithSubmissionLimit $form, MailMessage $message): MailMessage { $subjectPrefix = ''; @@ -22,10 +22,11 @@ public function addSubjectPrefixToMail(FormWithSubmissionLimit $form, MailMessag } $subject = $subjectPrefix . $message->getSubject(); - $message->setSubject($subject); + + return $message->setSubject($subject); } - public function addBodyPrefixHeaderAndTextToView(FormWithSubmissionLimit $form, StandaloneView $standaloneView, array $email) + public function getNewViewWithBodyPrefix(FormWithSubmissionLimit $form, StandaloneView $standaloneView, array $email): StandaloneView { $bodyPrefixHeader = ''; $bodyPrefixText = ''; @@ -41,6 +42,8 @@ public function addBodyPrefixHeaderAndTextToView(FormWithSubmissionLimit $form, $bodyPrefix = sprintf('

%s

%s


', $bodyPrefixHeader, $bodyPrefixText); $email['rteBody'] = $bodyPrefix . $email['rteBody']; $standaloneView->assign('powermail_rte', $email['rteBody']); + + return $standaloneView; } private function getTranslation(string $key): ?string