From a6a3b2fb511242e307ddda207df29ac25311ce46 Mon Sep 17 00:00:00 2001 From: Louis Jeckel Date: Wed, 13 Jan 2021 22:40:44 +0100 Subject: [PATCH] transform data-href-template to href from unlayer tools --- app/Jobs/ProcessEmailBatch.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/app/Jobs/ProcessEmailBatch.php b/app/Jobs/ProcessEmailBatch.php index 5ce434e..0faa7c5 100644 --- a/app/Jobs/ProcessEmailBatch.php +++ b/app/Jobs/ProcessEmailBatch.php @@ -213,6 +213,9 @@ class ProcessEmailBatch implements ShouldQueue } + /** + * @return array + */ public function processVariablesForMailgun() { if($this->html === null) { @@ -225,8 +228,27 @@ class ProcessEmailBatch implements ShouldQueue $match = Str::before(Str::after($matches[0], '{{'), '}}'); $variables[$match] = $match ; return "%recipient.$match%"; - }, $this->html); + }, self::processLinks($this->html)); return $variables; } + + /** + * @param $content + * @return string|string[]|null + * Transforms data-href-variable="template" to href="{{template}}" + */ + public static function processLinks($content) + { + return preg_replace_callback('/data-href-variable="([^(" )]*)"/', function($matches){ + $match = $matches[1]; + return sprintf('href="{{%s}}"', $match); + + }, $content); + } + + } + + + -- 2.39.5