Merge pull request #9660 from colemanw/CRM-19769
[civicrm-core.git] / Civi / Token / TokenCompatSubscriber.php
index 104d9f1117c51ac25e382a1cdc10c643eaff231f..e6c2f72e65f2a1d17c819a9d7f261d72a6b5c5e0 100644 (file)
@@ -49,6 +49,7 @@ class TokenCompatSubscriber implements EventSubscriberInterface {
     $messageTokens = $e->getTokenProcessor()->getMessageTokens();
 
     foreach ($e->getRows() as $row) {
+      /** @var int $contactId */
       $contactId = $row->context['contactId'];
       if (empty($row->context['contact'])) {
         $params = array(
@@ -83,6 +84,10 @@ class TokenCompatSubscriber implements EventSubscriberInterface {
         $row->context['controller']
       );
 
+      // merge the custom tokens in the $contact array
+      if (!empty($contactArray[$contactId])) {
+        $contact = array_merge($contact, $contactArray[$contactId]);
+      }
       $row->context('contact', $contact);
     }
   }