From c7587decda8ca22f2db6778fd5765a2e3412fc97 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 29 Sep 2021 17:44:32 +1300 Subject: [PATCH] Move getCustomFieldTokens to the tokens class 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 --- CRM/Core/TokenTrait.php | 5 ++++- CRM/Utils/Token.php | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CRM/Core/TokenTrait.php b/CRM/Core/TokenTrait.php index bb236232decd..2f995b432669 100644 --- a/CRM/Core/TokenTrait.php +++ b/CRM/Core/TokenTrait.php @@ -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; } diff --git a/CRM/Utils/Token.php b/CRM/Utils/Token.php index 6e05a0d593fe..06dfc9d9bee6 100644 --- a/CRM/Utils/Token.php +++ b/CRM/Utils/Token.php @@ -1523,6 +1523,11 @@ public static function getUserTokenReplacement($token, $escapeSmarty = FALSE) { return $value; } + /** + * Do not use. + * + * @deprecated + */ protected static function _buildContributionTokens() { $key = 'contribution'; @@ -1544,6 +1549,10 @@ protected static function _buildContributionTokens() { } /** + * Do not use. + * + * @deprecated + * * Replace tokens for an entity. * @param string $entity * @param array $entityArray @@ -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