X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FContribute%2FTokens.php;h=d5f6fd3a768ed5d0fae1904726017fd1c34c659d;hb=f299f7db79fed6f3598c84302966bda087e7cac3;hp=d6aba8ff9e63e38dbf76ffe3d6fff6a4a97df980;hpb=39c3fbcda92848d435b973f403d041fff51e4d4e;p=civicrm-core.git diff --git a/CRM/Contribute/Tokens.php b/CRM/Contribute/Tokens.php index d6aba8ff9e..d5f6fd3a76 100644 --- a/CRM/Contribute/Tokens.php +++ b/CRM/Contribute/Tokens.php @@ -4,7 +4,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 5 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2019 | + | Copyright CiviCRM LLC (c) 2004-2020 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -41,7 +41,7 @@ class CRM_Contribute_Tokens extends \Civi\Token\AbstractTokenSubscriber { * @return array */ protected function getPassthruTokens() { - return array( + return [ 'contribution_page_id', 'receive_date', 'total_amount', @@ -50,11 +50,11 @@ class CRM_Contribute_Tokens extends \Civi\Token\AbstractTokenSubscriber { 'trxn_id', 'invoice_id', 'currency', - 'cancel_date', + 'contribution_cancel_date', 'receipt_date', 'thankyou_date', 'tax_amount', - ); + ]; } /** @@ -63,13 +63,14 @@ class CRM_Contribute_Tokens extends \Civi\Token\AbstractTokenSubscriber { * @return array */ protected function getAliasTokens() { - return array( + return [ 'id' => 'contribution_id', 'payment_instrument' => 'payment_instrument_id', 'source' => 'contribution_source', 'status' => 'contribution_status_id', 'type' => 'financial_type_id', - ); + 'cancel_date' => 'contribution_cancel_date', + ]; } /** @@ -97,8 +98,7 @@ class CRM_Contribute_Tokens extends \Civi\Token\AbstractTokenSubscriber { * @return bool */ public function checkActive(\Civi\Token\TokenProcessor $processor) { - return - !empty($processor->context['actionMapping']) + return !empty($processor->context['actionMapping']) && $processor->context['actionMapping']->getEntity() === 'civicrm_contribution'; } @@ -129,7 +129,7 @@ class CRM_Contribute_Tokens extends \Civi\Token\AbstractTokenSubscriber { $fieldValue = isset($actionSearchResult->{"contrib_$field"}) ? $actionSearchResult->{"contrib_$field"} : NULL; $aliasTokens = $this->getAliasTokens(); - if (in_array($field, array('total_amount', 'fee_amount', 'net_amount'))) { + if (in_array($field, ['total_amount', 'fee_amount', 'net_amount'])) { return $row->format('text/plain')->tokens($entity, $field, \CRM_Utils_Money::format($fieldValue, $actionSearchResult->contrib_currency)); }