Skip to content
Snippets Groups Projects
Commit 0575cc2a authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Restoring default template fallback

parent 3c7b3594
No related branches found
No related tags found
No related merge requests found
......@@ -170,9 +170,10 @@ class MailTemplateService {
* @param array $markers
* @return string
*/
public static function registerTemplate($extension, $templateName, $description, array $markers) {
public static function registerTemplate($extension, $templateName, $templatePath, $description, array $markers) {
MailTemplateService::$registerArray[$extension][$templateName] = [
'templatePath' => $templatePath,
'description' => $description,
'marker' => $markers,
'extension' => $extension,
......@@ -205,17 +206,24 @@ class MailTemplateService {
$this->extensionKey, $this->templateName, $this->language
)->getFirst();
// If there is no template for this language, use the english template
if ($template === NULL && $this->language !== 'en') {
$this->setLanguage('en');
$this->sendEmail();
// If there is no template for this language, use the default template
if ($template === NULL) {
$templatePath = self::$registerArray[$this->extensionKey][$this->templateName]['templatePath'];
$templateFile = $templatePath . $this->language . '.template.html';
if (file_exists($templateFile)) {
$defaultTemplateContent = file_get_contents($templatePath . $this->language . '.template.html');
} else {
// no language found and no default template
return FALSE;
}
}
if ($template === NULL) {
return FALSE;
if (!isset($defaultTemplateContent)) {
$emailView->setTemplateSource($template->getContent());
} else {
$emailView->setTemplateSource($defaultTemplateContent);
}
$emailView->setTemplateSource($template->getContent());
$emailView->assignMultiple($this->markers);
$emailBody = $emailView->render();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment