update
This commit is contained in:
@@ -63,6 +63,7 @@ final class EmailSendingService
|
||||
$variableMap = $this->variableResolver->buildVariableMap($order, $addresses, $companySettings);
|
||||
$resolvedSubject = $this->variableResolver->resolve((string) ($template['subject'] ?? ''), $variableMap);
|
||||
$resolvedBody = $this->variableResolver->resolve((string) ($template['body_html'] ?? ''), $variableMap);
|
||||
$resolvedBody = $this->composeBody($resolvedBody, $mailbox, $variableMap);
|
||||
|
||||
$attachments = [];
|
||||
$attachmentType = (string) ($template['attachment_1'] ?? '');
|
||||
@@ -142,6 +143,9 @@ final class EmailSendingService
|
||||
$resolvedSubject = $this->variableResolver->resolve((string) ($template['subject'] ?? ''), $variableMap);
|
||||
$resolvedBody = $this->variableResolver->resolve((string) ($template['body_html'] ?? ''), $variableMap);
|
||||
|
||||
$mailbox = $this->resolveMailbox(null, $template);
|
||||
$resolvedBody = $this->composeBody($resolvedBody, $mailbox, $variableMap);
|
||||
|
||||
$attachmentNames = [];
|
||||
$attachmentType = (string) ($template['attachment_1'] ?? '');
|
||||
if ($attachmentType !== '') {
|
||||
@@ -158,6 +162,38 @@ final class EmailSendingService
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed>|null $mailbox
|
||||
* @param array<string, string> $variableMap
|
||||
*/
|
||||
private function composeBody(string $resolvedBody, ?array $mailbox, array $variableMap): string
|
||||
{
|
||||
if ($mailbox === null) {
|
||||
return $resolvedBody;
|
||||
}
|
||||
|
||||
$header = trim((string) ($mailbox['header_html'] ?? ''));
|
||||
$footer = trim((string) ($mailbox['footer_html'] ?? ''));
|
||||
|
||||
if ($header !== '') {
|
||||
$header = $this->variableResolver->resolve($header, $variableMap);
|
||||
}
|
||||
if ($footer !== '') {
|
||||
$footer = $this->variableResolver->resolve($footer, $variableMap);
|
||||
}
|
||||
|
||||
$parts = [];
|
||||
if ($header !== '') {
|
||||
$parts[] = $header;
|
||||
}
|
||||
$parts[] = $resolvedBody;
|
||||
if ($footer !== '') {
|
||||
$parts[] = $footer;
|
||||
}
|
||||
|
||||
return implode("\n", $parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed>|null $template
|
||||
* @return array<string, mixed>|null
|
||||
|
||||
Reference in New Issue
Block a user