From 9b2aa355b9cf13bf8f9470d6324e194ba88fd4a8 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Thu, 23 Feb 2017 22:04:56 -0500 Subject: [PATCH] Little progress, but still something --- .../Emails/EmailTemplateParser.php | 66 +++++++++++++++++++ .../Emails/EmailTemplateRetriever.php | 48 -------------- .../InvalidEmailTemplateException.php | 16 +++++ 3 files changed, 82 insertions(+), 48 deletions(-) create mode 100644 api/BusinessLogic/Emails/EmailTemplateParser.php delete mode 100644 api/BusinessLogic/Emails/EmailTemplateRetriever.php create mode 100644 api/BusinessLogic/Exceptions/InvalidEmailTemplateException.php 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 @@ -