From ad898cc94861b74505d63b94b966b4c049570e64 Mon Sep 17 00:00:00 2001 From: Igor Manjencic Date: Wed, 13 Dec 2023 10:13:23 +0100 Subject: [PATCH] feat(ZMS-1711): fix custom template --- zmsdb/src/Zmsdb/Calldisplay.php | 1 - .../src/Zmsentities/Helper/Messaging.php | 33 ++++++------------- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/zmsdb/src/Zmsdb/Calldisplay.php b/zmsdb/src/Zmsdb/Calldisplay.php index 220efa74c..b525f5531 100644 --- a/zmsdb/src/Zmsdb/Calldisplay.php +++ b/zmsdb/src/Zmsdb/Calldisplay.php @@ -86,7 +86,6 @@ public function readImage(Entity $entity) ->getQueryImage(), ['name' => "logo.png"]); } - return null; $mime = pathinfo($image['name'], PATHINFO_EXTENSION); $image['mime'] = ($mime == 'jpg') ? 'jpeg' : $mime; return $image; diff --git a/zmsentities/src/Zmsentities/Helper/Messaging.php b/zmsentities/src/Zmsentities/Helper/Messaging.php index 65272ce37..fc0090d10 100644 --- a/zmsentities/src/Zmsentities/Helper/Messaging.php +++ b/zmsentities/src/Zmsentities/Helper/Messaging.php @@ -115,9 +115,10 @@ public static function getMailContent( } $template = self::getTemplate('mail', $status, $mainProcess); - if ($initiator) { - $template = self::getTemplate('admin', $status); - } + return $template; + //if ($initiator) { + // $template = self::getTemplate('admin', $status); + //} if (!$template) { $exception = new \BO\Zmsentities\Exception\TemplateNotFound("Template for status $status not found"); $exception->data = $status; @@ -195,11 +196,13 @@ public static function getNotificationContent(Process $process, Config $config, protected static function getTemplate($type, $status, ?Process $process = null) { - $providerName = $process->getCurrentScope()->getProvider()->getDisplayName(); - $providerTemplate = 'custom/' . $type . '/' . $status . '/' . (self::slugify($providerName)) . '.twig'; + if ($process) { + $providerName = $process->getCurrentScope()->getProvider()->getName(); + $providerTemplate = 'custom/' . $type . '/' . $status . '/' . $providerName . '.twig'; - if (file_exists('messaging/' . $providerTemplate)) { - return $providerTemplate; + if (file_exists(TemplateFinder::getTemplatePath() . '/messaging/' . $providerTemplate)) { + return $providerTemplate; + } } $template = null; @@ -211,22 +214,6 @@ protected static function getTemplate($type, $status, ?Process $process = null) return $template; } - private static function slugify($text, string $divider = '_') - { - $text = preg_replace('~[^\pL\d]+~u', $divider, $text); - $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); - $text = preg_replace('~[^-\w]+~', '', $text); - $text = trim($text, $divider); - $text = preg_replace('~-+~', $divider, $text); - $text = strtolower($text); - - if (empty($text)) { - return 'none'; - } - - return $text; - } - public static function getMailSubject( Process $process, Config $config,