pass the mailing job id to hook token values
[civicrm-core.git] / Civi / Token / TokenCompatSubscriber.php
index ccd70813bf00efce9d2f1efa43ae23bc03588896..8e2ac735ba1b176cb5216da295183ec7733282b9 100644 (file)
@@ -90,7 +90,7 @@ class TokenCompatSubscriber implements EventSubscriberInterface {
       // less randomly.
       \CRM_Utils_Hook::tokenValues($contactArray,
         (array) $contactId,
-        empty($row->context['mailingJob']) ? NULL : $row->context['mailingJob']->id,
+        empty($row->context['mailingJobId']) ? NULL : $row->context['mailingJobId'],
         $messageTokens,
         $row->context['controller']
       );
@@ -112,7 +112,8 @@ class TokenCompatSubscriber implements EventSubscriberInterface {
     $isHtml = ($e->message['format'] == 'text/html');
     $useSmarty = !empty($e->context['smarty']);
 
-    $e->string = \CRM_Utils_Token::replaceDomainTokens($e->string, \CRM_Core_BAO_Domain::getDomain(), $isHtml, $e->message['tokens'], $useSmarty);
+    $domain = \CRM_Core_BAO_Domain::getDomain();
+    $e->string = \CRM_Utils_Token::replaceDomainTokens($e->string, $domain, $isHtml, $e->message['tokens'], $useSmarty);
 
     if (!empty($e->context['contact'])) {
       $e->string = \CRM_Utils_Token::replaceContactTokens($e->string, $e->context['contact'], $isHtml, $e->message['tokens'], TRUE, $useSmarty);