Merge pull request #13766 from eileenmcnaughton/api_between
[civicrm-core.git] / Civi / Token / AbstractTokenSubscriber.php
index 9609ecca48ba01fba97fc27f38f550f0f4b88d88..69a570f8f380ca1ce5657dc4d03c80f944ed5ed5 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018                                |
+ | Copyright CiviCRM LLC (c) 2004-2019                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -71,14 +71,22 @@ abstract class AbstractTokenSubscriber implements EventSubscriberInterface {
 
   /**
    * @var array
-   *   Ex: array('viewUrl', 'editUrl').
+   *   List of tokens provided by this class
+   *   Array(string $fieldName => string $label).
    */
   public $tokenNames;
 
+  /**
+   * @var array
+   *   List of active tokens - tokens provided by this class and used in the message
+   *   Array(string $tokenName);
+   */
+  public $activeTokens;
+
   /**
    * @param $entity
    * @param array $tokenNames
-   *   Array(string $fieldName => string $label).
+   *   Array(string $tokenName => string $label).
    */
   public function __construct($entity, $tokenNames = array()) {
     $this->entity = $entity;
@@ -143,14 +151,14 @@ abstract class AbstractTokenSubscriber implements EventSubscriberInterface {
       return;
     }
 
-    $activeTokens = $this->getActiveTokens($e);
-    if (!$activeTokens) {
+    $this->activeTokens = $this->getActiveTokens($e);
+    if (!$this->activeTokens) {
       return;
     }
     $prefetch = $this->prefetch($e);
 
     foreach ($e->getRows() as $row) {
-      foreach ((array) $activeTokens as $field) {
+      foreach ($this->activeTokens as $field) {
         $this->evaluateToken($row, $this->entity, $field, $prefetch);
       }
     }