diff --git a/api/BusinessLogic/Emails/EmailTemplateParser.php b/api/BusinessLogic/Emails/EmailTemplateParser.php new file mode 100644 index 00000000..6f2fa836 --- /dev/null +++ b/api/BusinessLogic/Emails/EmailTemplateParser.php @@ -0,0 +1,66 @@ +statusGateway = $statusGateway; + } + + /** + * @param $templateName string + * @param $language string + * @param $ticket Ticket + */ + function getFormattedEmailForLanguage($templateName, $language, $ticket) { + global $hesklang; + + $template = self::getFromFileSystem($templateName, $language); + $subject = ValidEmailTemplates::getValidEmailTemplates()[$templateName]; + + $subject = self::parseSubject($subject, $ticket); + } + + private function getFromFileSystem($template, $language) + { + if (!isset(ValidEmailTemplates::getValidEmailTemplates()[$template])) { + throw new InvalidEmailTemplateException($template); + } + + /* Get email template */ + $file = 'language/' . $language . '/emails/' . $template . '.txt'; + $absoluteFilePath = __DIR__ . '/../../../' . $file; + + if (file_exists($absoluteFilePath)) { + return file_get_contents($absoluteFilePath); + } else { + throw new EmailTemplateNotFoundException($template, $language); + } + } + + private static function parseSubject($subjectTemplate, $ticket) { + if ($ticket === null) { + return $subjectTemplate; + } + + //-- + } +} \ No newline at end of file diff --git a/api/BusinessLogic/Emails/EmailTemplateRetriever.php b/api/BusinessLogic/Emails/EmailTemplateRetriever.php deleted file mode 100644 index cab2e26b..00000000 --- a/api/BusinessLogic/Emails/EmailTemplateRetriever.php +++ /dev/null @@ -1,48 +0,0 @@ -