X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FTokenTrait.php;h=2f995b432669c9b4e27eb6859622f36f81c7b3a5;hb=7be60c2d30b539f58ec1c365c284e7f26573b720;hp=a2940b23e6f5134318c72f97aea277d873e0c9ed;hpb=dc7f057aa1428750d240634af100a20a11ab9cbe;p=civicrm-core.git diff --git a/CRM/Core/TokenTrait.php b/CRM/Core/TokenTrait.php index a2940b23e6..2f995b4326 100644 --- a/CRM/Core/TokenTrait.php +++ b/CRM/Core/TokenTrait.php @@ -1,5 +1,8 @@ getEntityContextSchema(), $processor->context['schema']) || (!empty($processor->context['actionMapping']) && $processor->context['actionMapping']->getEntity() === $this->getEntityTableName()); @@ -27,7 +34,7 @@ trait CRM_Core_TokenTrait { /** * @inheritDoc */ - public function getActiveTokens(\Civi\Token\Event\TokenValueEvent $e) { + public function getActiveTokens(TokenValueEvent $e) { $messageTokens = $e->getTokenProcessor()->getMessageTokens(); if (!isset($messageTokens[$this->entity])) { return NULL; @@ -51,17 +58,15 @@ trait CRM_Core_TokenTrait { /** * Find the fields that we need to get to construct the tokens requested. - * @param array $activeTokens list of active tokens + * * @return array list of fields needed to generate those tokens */ - public function getReturnFields($activeTokens) { + public function getReturnFields(): array { // Make sure we always return something $fields = ['id']; - $tokensInUse = array_intersect( - $activeTokens, - array_merge(array_keys(self::getBasicTokens()), array_keys(self::getCustomFieldTokens())) - ); + $tokensInUse = + array_merge(array_keys(self::getBasicTokens()), array_keys(self::getCustomFieldTokens())); foreach ($tokensInUse as $token) { if (isset(self::$fieldMapping[$token])) { $fields = array_merge($fields, self::$fieldMapping[$token]); @@ -77,9 +82,12 @@ trait CRM_Core_TokenTrait { * Get the tokens for custom fields * @return array token name => token label */ - protected function getCustomFieldTokens() { + 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; }