]> _ Git - psq.git/commitdiff
transform data-href-template to href from unlayer tools
authorLouis Jeckel <louis.jeckel@outlook.com>
Wed, 13 Jan 2021 21:40:44 +0000 (22:40 +0100)
committerLouis Jeckel <louis.jeckel@outlook.com>
Wed, 13 Jan 2021 21:40:44 +0000 (22:40 +0100)
app/Jobs/ProcessEmailBatch.php

index 5ce434efa29a001be5463fafce38d0248e9b05b8..0faa7c5d8443ca8589925bc855a1e7d4dc496d41 100644 (file)
@@ -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);
+    }
+
+
 }
+
+
+