Skip to content

Commit

Permalink
feat(ZMS-1711): fix custom template
Browse files Browse the repository at this point in the history
  • Loading branch information
manjencic committed Dec 13, 2023
1 parent 0f98d18 commit ad898cc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
1 change: 0 additions & 1 deletion zmsdb/src/Zmsdb/Calldisplay.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
33 changes: 10 additions & 23 deletions zmsentities/src/Zmsentities/Helper/Messaging.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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,
Expand Down

0 comments on commit ad898cc

Please sign in to comment.