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.
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());
}
/**