Skip to content

Commit

Permalink
Merge pull request #64 from it-at-m/feature-1711-custom-mail-templates
Browse files Browse the repository at this point in the history
feat(ZMS-1711): fix custom template
  • Loading branch information
manjencic authored Dec 13, 2023
2 parents 080407e + b19f436 commit b374dab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 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
26 changes: 6 additions & 20 deletions zmsentities/src/Zmsentities/Helper/Messaging.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,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 +213,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 b374dab

Please sign in to comment.