diff --git a/CRM/Activity/Form/Task/PDFLetterCommon.php b/CRM/Activity/Form/Task/PDFLetterCommon.php index 7af6c006cfe0dbc9a0d956ca5fa62783a0224b6e..424249fb5c8a2e28ce12d651fee9fb5ad8e25a26 100644 --- a/CRM/Activity/Form/Task/PDFLetterCommon.php +++ b/CRM/Activity/Form/Task/PDFLetterCommon.php @@ -53,7 +53,7 @@ class CRM_Activity_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLette $tp->addMessage('body_html', $html_message, 'text/html'); foreach ($activityIds as $activityId) { - $tp->addRow()->context('activity_id', $activityId); + $tp->addRow()->context('activityId', $activityId); } $tp->evaluate(); @@ -69,7 +69,7 @@ class CRM_Activity_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLette return new TokenProcessor(\Civi::dispatcher(), [ 'controller' => get_class(), 'smarty' => FALSE, - 'schema' => ['activity_id'], + 'schema' => ['activityId'], ]); } diff --git a/CRM/Activity/Tokens.php b/CRM/Activity/Tokens.php index e8d875c5e7ad852fc16f5d0b1fe9d3d9a2af19a3..fff8e6224a507fe684cf1465cbf0881d7365ca91 100644 --- a/CRM/Activity/Tokens.php +++ b/CRM/Activity/Tokens.php @@ -48,12 +48,10 @@ class CRM_Activity_Tokens extends \Civi\Token\AbstractTokenSubscriber { } /** - * Get the name of the field which holds the ID of the given entity. - * * @return string */ - private function getEntityIDFieldName(): string { - return 'activity_id'; + private function getEntityContextSchema(): string { + return 'activityId'; } /** @@ -90,7 +88,7 @@ class CRM_Activity_Tokens extends \Civi\Token\AbstractTokenSubscriber { // Find all the entity IDs $entityIds = $e->getTokenProcessor()->getContextValues('actionSearchResult', 'entityID') - + $e->getTokenProcessor()->getContextValues($this->getEntityIDFieldName()); + + $e->getTokenProcessor()->getContextValues($this->getEntityContextSchema()); if (!$entityIds) { return NULL; @@ -124,8 +122,6 @@ class CRM_Activity_Tokens extends \Civi\Token\AbstractTokenSubscriber { /** * @inheritDoc - * - * @throws \CRM_Core_Exception */ public function evaluateToken(\Civi\Token\TokenRow $row, $entity, $field, $prefetch = NULL) { // maps token name to api field @@ -134,7 +130,7 @@ class CRM_Activity_Tokens extends \Civi\Token\AbstractTokenSubscriber { ]; // Get ActivityID either from actionSearchResult (for scheduled reminders) if exists - $activityId = $row->context['actionSearchResult']->entityID ?? $row->context[$this->getEntityIDFieldName()]; + $activityId = $row->context['actionSearchResult']->entityID ?? $row->context[$this->getEntityContextSchema()]; $activity = (object) $prefetch['activity'][$activityId]; diff --git a/CRM/Core/TokenTrait.php b/CRM/Core/TokenTrait.php index bd77c7dc693ac1d6b307ae97008d820b4127a141..26110155eff60f3b96140e65f0cd8087da1df0b5 100644 --- a/CRM/Core/TokenTrait.php +++ b/CRM/Core/TokenTrait.php @@ -19,7 +19,7 @@ trait CRM_Core_TokenTrait { * @inheritDoc */ public function checkActive(\Civi\Token\TokenProcessor $processor) { - return in_array($this->getEntityIDFieldName(), $processor->context['schema'], TRUE) || + return in_array($this->getEntityContextSchema(), $processor->context['schema']) || (!empty($processor->context['actionMapping']) && $processor->context['actionMapping']->getEntity() === $this->getEntityTableName()); } @@ -51,7 +51,6 @@ trait CRM_Core_TokenTrait { /** * Find the fields that we need to get to construct the tokens requested. - * * @param array $tokens list of tokens * @return array list of fields needed to generate those tokens */ diff --git a/Civi/Token/TokenProcessor.php b/Civi/Token/TokenProcessor.php index 0d1ff138db5038887eabfea041e2678d365e6df0..e8ee1b8f73f5d65f8d331284ac67eff50b168512 100644 --- a/Civi/Token/TokenProcessor.php +++ b/Civi/Token/TokenProcessor.php @@ -58,7 +58,7 @@ class TokenProcessor { * - schema: array, a list of fields that will be provided for each row. * This is automatically populated with any general context * keys, but you may need to add extra keys for token-row data. - * ex: ['contactId', 'activity_id']. (Note we are standardising on the latter). + * ex: ['contactId', 'activityId']. */ public $context;