4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
7 | This work is published under the GNU AGPLv3 license with some |
8 | permitted exceptions and without any warranty. For full license |
9 | and copyright information, see https://civicrm.org/licensing |
10 +--------------------------------------------------------------------+
14 * Class CRM_Contribute_Tokens
16 * Generate "contribution.*" tokens.
18 * At time of writing, we don't have any particularly special tokens -- we just
19 * do some basic formatting based on the corresponding DB field.
21 class CRM_Contribute_Tokens
extends CRM_Core_EntityTokens
{
26 protected function getEntityName(): string {
27 return 'contribution';
33 protected function getEntityAlias(): string {
38 * Get the entity name for api v4 calls.
40 * In practice this IS just ucfirst($this->GetEntityName)
41 * but declaring it seems more legible.
45 protected function getApiEntityName(): string {
46 return 'Contribution';
50 * Get a list of tokens for the entity for which access is permitted to.
52 * This list is historical and we need to question whether we
53 * should filter out any fields (other than those fields, like api_key
54 * on the contact entity) with permissions defined.
58 protected function getExposedFields(): array {
60 'contribution_page_id',
67 'non_deductible_amount',
75 'contribution_status_id',
77 'payment_instrument_id',
82 if (CRM_Campaign_BAO_Campaign
::isCampaignEnable()) {
83 $fields[] = 'campaign_id';
89 * Get tokens supporting the syntax we are migrating to.
91 * In general these are tokens that were not previously supported
92 * so we can add them in the preferred way or that we have
93 * undertaken some, as yet to be written, db update.
95 * See https://lab.civicrm.org/dev/core/-/issues/2650
99 public function getBasicTokens(): array {
101 foreach ($this->getExposedFields() as $fieldName) {
102 $return[$fieldName] = $this->getFieldMetadata()[$fieldName]['title'];