From 3232ec1374696a4376a7fd65d6959f3596b6d3ec 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 | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CRM/Core/TokenTrait.php b/CRM/Core/TokenTrait.php index bb236232de..2f995b4326 100644 --- a/CRM/Core/TokenTrait.php +++ b/CRM/Core/TokenTrait.php @@ -84,7 +84,10 @@ trait CRM_Core_TokenTrait { */ 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 58b9581ac1..421e7cefc1 100644 --- a/CRM/Utils/Token.php +++ b/CRM/Utils/Token.php @@ -1561,6 +1561,10 @@ class CRM_Utils_Token { } /** + * Do not use. + * + * @deprecated + * * Replace tokens for an entity. * @param string $entity * @param array $entityArray @@ -1873,6 +1877,8 @@ class CRM_Utils_Token { /** * Get all custom field tokens of $entity * + * @deprecated + * * @param string $entity * @return array * return custom field tokens in array('custom_N' => 'label') format -- 2.25.1