$value = "{action.$token}";
}
else {
- $value = CRM_Utils_Array::value($token, $addresses);
+ $value = $addresses[$token] ?? NULL;
if ($value == NULL) {
- $value = CRM_Utils_Array::value($token, $urls);
+ $value = $urls[$token] ?? NULL;
}
if ($value && $html) {
$noReplace = TRUE;
}
elseif ($token == 'checksum') {
- $hash = CRM_Utils_Array::value('hash', $contact);
+ $hash = $contact['hash'] ?? NULL;
$contactID = CRM_Utils_Array::retrieveValueRecursive($contact, 'contact_id');
$cs = CRM_Contact_BAO_Contact_Utils::generateChecksum($contactID,
NULL,
$html = FALSE,
$escapeSmarty = FALSE
) {
- $value = CRM_Utils_Array::value("{$category}.{$token}", $contact);
+ $value = $contact["{$category}.{$token}"] ?? NULL;
if ($value && !$html) {
$value = str_replace('&', '&', $value);
}
$details = CRM_Contact_BAO_Query::apiQuery($params, $returnProperties, NULL, NULL, 0, count($contactIDs), TRUE, FALSE, TRUE, CRM_Contact_BAO_Query::MODE_CONTACTS, NULL, TRUE);
-
$contactDetails = &$details[0];
foreach ($contactIDs as $contactID) {
}
}
+ // $contactDetails = &$details[0] = is an array of [ contactID => contactDetails ]
// also call a hook and get token details
- CRM_Utils_Hook::tokenValues($details[0],
+ CRM_Utils_Hook::tokenValues($contactDetails,
$contactIDs,
$jobID,
$tokens,
* @return array
* contactDetails with hooks swapped out
*/
- public static function getAnonymousTokenDetails($contactIDs = [
- 0,
- ],
+ public static function getAnonymousTokenDetails($contactIDs = [0],
$returnProperties = NULL,
$skipOnHold = TRUE,
$skipDeceased = TRUE,
}
$field = civicrm_api3($entity, 'getfield', ['action' => 'get', 'name' => $token, 'get_options' => 'get']);
$field = $field['values'];
- $fieldType = CRM_Utils_Array::value('type', $field);
+ $fieldType = $field['type'] ?? NULL;
// Boolean fields
if ($fieldType == CRM_Utils_Type::T_BOOLEAN && empty($field['options'])) {
$field['options'] = [ts('No'), ts('Yes')];
*/
public static function replaceContributionTokens($str, &$contribution, $html = FALSE, $knownTokens = NULL, $escapeSmarty = FALSE) {
$key = 'contribution';
- if (!$knownTokens || !CRM_Utils_Array::value($key, $knownTokens)) {
+ if (!$knownTokens || empty($knownTokens[$key])) {
//early return
return $str;
}