From: Tim Otten Date: Tue, 12 Oct 2021 07:43:17 +0000 (-0700) Subject: EntityTokens - Normalize data-loading via `myEntityId` (eg `activityId`) X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=afd0de5df057ad36aa2c42f2585dcf2c26327d7d;p=civicrm-core.git EntityTokens - Normalize data-loading via `myEntityId` (eg `activityId`) Before ====== EntityTokens has two protocols for fetching data: 1. For scheduled-reminders, hook into the main query. Add N-ary columns to select any fields used by tokens. 2. For everything else, expect a parameter `$row->context['activityId']`. Collect the `activityId`s and fetch the needful via APIv4. This poses a few challenges, but TLDR it's duplicate functionality. That means that listeners who consume the `activityId` must check multiple places. It means that the data-loading could return slightly different data (ie based on SQL query vs API data-loader). After ===== * EntityTokens has one protocol for fetching data: it must receive `activityId`s and then call APIv4 for the batch. * For scheduled-reminders, EntityTokens uses a small adapter to ensure that `activityId`s are available. --- diff --git a/CRM/Core/EntityTokens.php b/CRM/Core/EntityTokens.php index c1cb2fcbc4..c9ff0128cd 100644 --- a/CRM/Core/EntityTokens.php +++ b/CRM/Core/EntityTokens.php @@ -349,9 +349,7 @@ class CRM_Core_EntityTokens extends AbstractTokenSubscriber { if ($e->mapping->getEntity() !== $this->getExtendableTableName()) { return; } - foreach ($this->getReturnFields() as $token) { - $e->query->select('e.' . $token . ' AS ' . $this->getEntityAlias() . $token); - } + $e->query->select('e.id AS tokenContext_' . $this->getEntityIDField()); } /**