From 1ee56218b7aa8ecad64128f5ff57e3290aac9be9 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 14 Sep 2021 15:05:55 +1200 Subject: [PATCH] [Ref] Cleanup on SelectValues::contributeTokens This has 100% test cover in the ByTypeTest::testTokenRendering test The change means we no longer need the recently-added function to be public & hence it is switched to protected. Note this is the same as the equivalent contactTokens function --- CRM/Core/EntityTokens.php | 3 ++- CRM/Core/SelectValues.php | 10 +++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/CRM/Core/EntityTokens.php b/CRM/Core/EntityTokens.php index ad86cd6d5b..aa49ea1746 100644 --- a/CRM/Core/EntityTokens.php +++ b/CRM/Core/EntityTokens.php @@ -122,8 +122,9 @@ class CRM_Core_EntityTokens extends AbstractTokenSubscriber { * Get all the tokens supported by this processor. * * @return array|string[] + * @throws \API_Exception */ - public function getAllTokens(): array { + protected function getAllTokens(): array { $basicTokens = $this->getBasicTokens(); foreach (array_keys($basicTokens) as $fieldName) { // The goal is to be able to render more complete tokens diff --git a/CRM/Core/SelectValues.php b/CRM/Core/SelectValues.php index bad8099b4b..65509d23ea 100644 --- a/CRM/Core/SelectValues.php +++ b/CRM/Core/SelectValues.php @@ -560,17 +560,13 @@ class CRM_Core_SelectValues { } /** - * Different type of Event Tokens. + * Different type of Contribution Tokens. * * @return array */ public static function contributionTokens(): array { - $tokens = []; - $processor = new CRM_Contribute_Tokens(); - foreach ($processor->getAllTokens() as $token => $title) { - $tokens['{contribution.' . $token . '}'] = $title; - } - return $tokens; + $tokenProcessor = new TokenProcessor(Civi::dispatcher(), ['schema' => ['contributionId']]); + return $tokenProcessor->listTokens(); } /** -- 2.25.1