test fixes
authorKurund Jalmi <kurundjalmi@thirdsectordesign.org>
Wed, 25 Oct 2023 22:06:49 +0000 (23:06 +0100)
committerKurund Jalmi <kurundjalmi@thirdsectordesign.org>
Wed, 6 Dec 2023 00:23:34 +0000 (00:23 +0000)
ext/afform/core/Civi/Afform/Tokens.php

index 093f1b02b0ea9eae83e43440b259937e93ec8b3e..c7b901f94428ec334765f7652d85365d714df4cd 100644 (file)
@@ -111,6 +111,11 @@ class Tokens extends AutoService implements EventSubscriberInterface {
   }
 
   public static function listTokens(\Civi\Token\Event\TokenRegisterEvent $e) {
+    // this tokens should be available only in contact context i.e. in Message Templates (add/edit)
+    if (!in_array('contactId', $e->getTokenProcessor()->getContextValues('schema')[0])) {
+      return;
+    }
+
     $e->entity('afformSubmission')
       ->register('validateSubmissionUrl', E::ts('Validate Submission URL'))
       ->register('validateSubmissionLink', E::ts('Validate Submission (Full Hyperlink)'));