+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2016 |
+ | Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
if (!$this->checkActive($e->getTokenProcessor())) {
return;
}
- // TODO: check if any tokens for $entity are actually used; short-circuit.
+
+ $messageTokens = $e->getTokenProcessor()->getMessageTokens();
+ if (!isset($messageTokens[$this->entity])) {
+ return;
+ }
+
+ $activeTokens = array_intersect($messageTokens[$this->entity], array_keys($this->tokenNames));
+
$prefetch = $this->prefetch($e);
+
foreach ($e->getRows() as $row) {
- foreach ($this->tokenNames as $field => $label) {
+ foreach ((array) $activeTokens as $field) {
$this->evaluateToken($row, $this->entity, $field, $prefetch);
}
}