Skip to content

Commit

Permalink
Move getCustomFieldTokens to the tokens class
Browse files Browse the repository at this point in the history
This deprecates (quietly) another function on CRM_Utils_Token. It's a pretty small function -
the sort you'd just copy & paste if you wanted to use outside of core but
I didn't add noise. The only core place that calls this is the tokenTrait
- which is 'used' by activity tokens - but only for the handling of _N_
which I think was actually not supposed to have been included in the merge.

Anyway - I'm leaving that question for later because I'm not sure if the token
trait is used outside of core or how our final interface will look
  • Loading branch information
eileenmcnaughton committed Oct 7, 2021
1 parent f78c7ae commit c7587de
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CRM/Core/TokenTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ public function getReturnFields(): array {
*/
protected function getCustomFieldTokens(): array {
if (!isset($this->customFieldTokens)) {
$this->customFieldTokens = \CRM_Utils_Token::getCustomFieldTokens(ucfirst($this->getEntityName()));
$this->customFieldTokens = [];
foreach (CRM_Core_BAO_CustomField::getFields(ucfirst($this->getEntityName())) as $id => $info) {
$this->customFieldTokens['custom_' . $id] = $info['label'] . ' :: ' . $info['groupTitle'];
}
}
return $this->customFieldTokens;
}
Expand Down
11 changes: 11 additions & 0 deletions CRM/Utils/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,11 @@ public static function getUserTokenReplacement($token, $escapeSmarty = FALSE) {
return $value;
}

/**
* Do not use.
*
* @deprecated
*/
protected static function _buildContributionTokens() {
$key = 'contribution';

Expand All @@ -1544,6 +1549,10 @@ protected static function _buildContributionTokens() {
}

/**
* Do not use.
*
* @deprecated
*
* Replace tokens for an entity.
* @param string $entity
* @param array $entityArray
Expand Down Expand Up @@ -1856,6 +1865,8 @@ public static function legacyContactTokens() {
/**
* Get all custom field tokens of $entity
*
* @deprecated
*
* @param string $entity
* @return array
* return custom field tokens in array('custom_N' => 'label') format
Expand Down

0 comments on commit c7587de

Please sign in to comment.