Commit dcb71303 authored by Fabian Galinski's avatar Fabian Galinski 😾
Browse files

[FEATURE] Adds a function to overwrite the email body

parent 752f8469
......@@ -104,6 +104,11 @@ class MailTemplateService {
*/
private $subject;
/**
* @var string $overwrittenEmailBody
*/
private $overwrittenEmailBody = '';
/**
* @var string $extensionKey
*/
......@@ -486,6 +491,20 @@ class MailTemplateService {
$this->subject = $subject;
}
/**
* @return string
*/
public function getOverwrittenEmailBody(): string {
return $this->overwrittenEmailBody;
}
/**
* @param string $overwrittenEmailBody
*/
public function setOverwrittenEmailBody(string $overwrittenEmailBody): void {
$this->overwrittenEmailBody = $overwrittenEmailBody;
}
/**
* Return default markers for sg_mail
*
......@@ -662,7 +681,8 @@ class MailTemplateService {
$emailView->setTemplateSource(\trim($template->getSubject()));
$subject = $emailView->render();
$emailView->setTemplateSource($template->getContent());
$overwrittenEmailBody = $this->getOverwrittenEmailBody();
$emailView->setTemplateSource(empty($overwrittenEmailBody) ? $template->getContent() : $overwrittenEmailBody);
} else {
$subject = $registerService->getRegisterArray()[$this->extensionKey][$this->templateName]['subject'];
if (\is_array($subject)) {
......@@ -678,7 +698,7 @@ class MailTemplateService {
$emailView->setTemplateSource($subject);
$subject = $emailView->render();
}
$emailView->setTemplateSource($defaultTemplateContent);
$emailView->setTemplateSource(empty($overwrittenEmailBody) ? $defaultTemplateContent : $overwrittenEmailBody);
}
if ($this->subject !== '' && $this->subject !== NULL) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment