X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=Civi%2FToken%2FTokenRow.php;h=4f186d3d5c1ea9ccf3d84806cc76e7b8d834554c;hb=bc17b73e442ebbec13b08acb7093f03a66495b96;hp=3c77f31d129afaa5b518ed671aa141de07195c28;hpb=cdedc5f3d54bf870f80f092af6f9676786fb99db;p=civicrm-core.git diff --git a/Civi/Token/TokenRow.php b/Civi/Token/TokenRow.php index 3c77f31d12..4f186d3d5c 100644 --- a/Civi/Token/TokenRow.php +++ b/Civi/Token/TokenRow.php @@ -126,6 +126,29 @@ class TokenRow { return $this; } + /** + * Update the value of a custom field token. + * + * @param string $entity + * @param int $customFieldID + * @param int $entityID + * @return TokenRow + */ + public function customToken($entity, $customFieldID, $entityID) { + $customFieldName = "custom_" . $customFieldID; + $fieldValue = civicrm_api3($entity, 'getvalue', array( + 'return' => $customFieldName, + 'id' => $entityID, + )); + + // format the raw custom field value into proper display value + if ($fieldValue) { + $fieldValue = \CRM_Core_BAO_CustomField::displayValue($fieldValue, $customFieldID); + } + + return $this->tokens($entity, $customFieldName, $fieldValue); + } + /** * Update the value of a token. Apply formatting based on DB schema. *