}
foreach ($this->apiFieldSpec as $field) {
if (
- $fieldName == \CRM_Utils_Array::value('uniqueName', $field) ||
- array_search($fieldName, \CRM_Utils_Array::value('api.aliases', $field, [])) !== FALSE
+ $fieldName == ($field['uniqueName'] ?? NULL) ||
+ array_search($fieldName, $field['api.aliases'] ?? []) !== FALSE
) {
return $field;
}
}
$fieldInfo = $fkField['FKApiSpec'][$fieldName] ?? NULL;
- $keyColumn = \CRM_Utils_Array::value('FKKeyColumn', $fkField, 'id');
+ $keyColumn = $fkField['FKKeyColumn'] ?? 'id';
if (!$fieldInfo || !isset($fkField['FKApiSpec'][$keyColumn])) {
// Join doesn't exist - might be another param with a dot in it for some reason, we'll just ignore it.
return NULL;
$words = preg_split("/[\s]+/", $item);
if ($words) {
// Direction defaults to ASC unless DESC is specified
- $direction = strtoupper(\CRM_Utils_Array::value(1, $words, '')) == 'DESC' ? ' DESC' : '';
+ $direction = strtoupper($words[1] ?? '') === 'DESC' ? ' DESC' : '';
$field = $this->getField($words[0]);
if ($field) {
$this->query->orderBy(self::MAIN_TABLE_ALIAS . '.' . $field['name'] . $direction, NULL, $index);
$defaultSubParams[$lowercase_entity . "_id"] = $parentAPIValues['id'];
}
}
- // @todo remove strtolower: $subEntity is already lower case
- if ($entity != 'Contact' && \CRM_Utils_Array::value(strtolower($subEntity . "_id"), $parentAPIValues)) {
+ if ($entity !== 'Contact' && !empty($parentAPIValues[$subEntity . '_id'])) {
//e.g. if event_id is in the values returned & subentity is event
//then pass in event_id as 'id' don't do this for contact as it
//does some weird things like returning primary email &
//thus limiting the ability to chain email
//TODO - this might need the camel treatment
- $defaultSubParams['id'] = $parentAPIValues[$subEntity . "_id"];
+ $defaultSubParams['id'] = $parentAPIValues[$subEntity . '_id'];
}
- if (\CRM_Utils_Array::value('entity_table', $result['values'][$idIndex]) == $subEntity) {
+ if (($result['values'][$idIndex]['entity_table'] ?? NULL) == $subEntity) {
$defaultSubParams['id'] = $result['values'][$idIndex]['entity_id'];
}
// if we are dealing with the same entity pass 'id' through
$this->authorizeDelegate(
$apiRequest['action'],
$apiRequest['params']['entity_table'],
- \CRM_Utils_Array::value('entity_id', $apiRequest['params'], NULL),
+ $apiRequest['params']['entity_id'] ?? NULL,
$apiRequest
);
return;
// Kind'a silly we need to (re(re))parse here for each rule; would be more
// performant if pre-parsed by Request::create().
$options = _civicrm_api3_get_options_from_params($apiRequest['params'], TRUE, $apiRequest['entity'], 'get');
- $return = \CRM_Utils_Array::value('return', $options, []);
+ $return = $options['return'] ?? [];
$activatedFields = array_merge($activatedFields, array_keys($return));
}
*/
protected function getMandatory($entity) {
if ($this->mandatory === NULL) {
- $this->mandatory = self::parseMandatorySettings(\CRM_Utils_Array::value('civicrm_setting', $GLOBALS));
+ $this->mandatory = self::parseMandatorySettings($GLOBALS['civicrm_setting'] ?? NULL);
}
return $this->mandatory[$entity];
}
// but it's tightly coupled to DAO/field. However, if you really need to support
// more pseudoconstant types, then probably best to refactor it. For now, KISS.
if (!empty($pseudoconstant['optionGroupName'])) {
- $keyColumn = \CRM_Utils_Array::value('keyColumn', $pseudoconstant, 'value');
+ $keyColumn = $pseudoconstant['keyColumn'] ?? 'value';
if (is_array($optionsFormat)) {
$optionValues = \CRM_Core_OptionValue::getValues(['name' => $pseudoconstant['optionGroupName']]);
foreach ($optionValues as $option) {
'return' => $customFieldName,
'id' => $entityID,
]);
- $fieldValue = \CRM_Utils_Array::value($customFieldName, $record, '');
+ $fieldValue = $record[$customFieldName] ?? '';
$originalValue = $fieldValue;
// format the raw custom field value into proper display value
if (isset($fieldValue)) {
if ($entity == 'activity' && $field == 'details') {
$htmlTokens[$entity][$field] = $value;
}
- elseif (\CRM_Utils_Array::value('data_type', \CRM_Utils_Array::value($field, $entityFields['values'])) == 'Memo') {
+ elseif (($entityFields['values'][$field]['data_type'] ?? NULL) === 'Memo') {
// Memo fields aka custom fields of type Note are html.
$htmlTokens[$entity][$field] = \CRM_Utils_String::purifyHTML($value);
}