From 52883911e46e513afbc70bbc61531274b5643fa3 Mon Sep 17 00:00:00 2001 From: Aidan Saunders Date: Wed, 5 Dec 2018 11:52:47 +0000 Subject: [PATCH] Make activeTokens a class property of \Civi\Token\AbstractTokenSubscriber --- Civi/Token/AbstractTokenSubscriber.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Civi/Token/AbstractTokenSubscriber.php b/Civi/Token/AbstractTokenSubscriber.php index d43b3411cf..69a570f8f3 100644 --- a/Civi/Token/AbstractTokenSubscriber.php +++ b/Civi/Token/AbstractTokenSubscriber.php @@ -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); } } -- 2.25.1