Skip to content
Snippets Groups Projects
Unverified Commit 950e438f authored by mattwire's avatar mattwire Committed by GitHub
Browse files

Merge pull request #17365 from eileenmcnaughton/pdf

Revert "[REF] Code readability changes on activity tokens."
parents 8d0e37b6 51e25a23
Branches
Tags
No related merge requests found
......@@ -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'],
]);
}
......
......@@ -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];
......
......@@ -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
*/
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment