This is a partial of https://github.com/civicrm/civicrm-core/pull/16768 & consists of the lines I have reviewed from it
*/
public static function add(&$params) {
$contact = new CRM_Contact_DAO_Contact();
- $contactID = CRM_Utils_Array::value('contact_id', $params);
+ $contactID = $params['contact_id'] ?? NULL;
if (empty($params)) {
return NULL;
}
$contact->sort_name = substr($contact->sort_name, 0, 128);
}
- $privacy = CRM_Utils_Array::value('privacy', $params);
+ $privacy = $params['privacy'] ?? NULL;
if ($privacy &&
is_array($privacy) &&
!empty($privacy)
//Sorting fields in alphabetical order(CRM-1507)
foreach ($fields as $k => $v) {
- $sortArray[$k] = CRM_Utils_Array::value('title', $v);
+ $sortArray[$k] = $v['title'] ?? NULL;
}
$fields = array_merge($sortArray, $fields);
$locationTypeName = 1;
}
else {
- $locationTypeName = CRM_Utils_Array::value($id, $locationTypes);
+ $locationTypeName = $locationTypes[$id] ?? NULL;
if (!$locationTypeName) {
continue;
}
$blocks = CRM_Core_BAO_Location::getValues($entityBlock);
foreach ($blocks[$block] as $key => $value) {
if (!empty($value['is_primary'])) {
- $locationType = CRM_Utils_Array::value('location_type_id', $value);
+ $locationType = $value['location_type_id'] ?? NULL;
}
}
}
$details = self::getHierContactDetails($contactID, $fields);
$contactDetails = $details[$contactID];
- $data['contact_type'] = CRM_Utils_Array::value('contact_type', $contactDetails);
- $data['contact_sub_type'] = CRM_Utils_Array::value('contact_sub_type', $contactDetails);
+ $data['contact_type'] = $contactDetails['contact_type'] ?? NULL;
+ $data['contact_sub_type'] = $contactDetails['contact_sub_type'] ?? NULL;
}
else {
//we should get contact type only if contact
}
if ($ctype == 'Organization') {
- $data['organization_name'] = CRM_Utils_Array::value('organization_name', $contactDetails);
+ $data['organization_name'] = $contactDetails['organization_name'] ?? NULL;
}
elseif ($ctype == 'Household') {
- $data['household_name'] = CRM_Utils_Array::value('household_name', $contactDetails);
+ $data['household_name'] = $contactDetails['household_name'] ?? NULL;
}
$locationType = [];
CRM_Core_OptionGroup::lookupValues($temp, $names, FALSE);
$values['preferred_communication_method'] = $preffComm;
- $values['preferred_communication_method_display'] = CRM_Utils_Array::value('preferred_communication_method_display', $temp);
+ $values['preferred_communication_method_display'] = $temp['preferred_communication_method_display'] ?? NULL;
if ($contact->preferred_mail_format) {
$preferredMailingFormat = CRM_Core_SelectValues::pmf();
$birthDate = CRM_Utils_Date::customFormat($contact->birth_date, '%Y%m%d');
if ($birthDate < date('Ymd')) {
$age = CRM_Utils_Date::calculateAge($birthDate);
- $values['age']['y'] = CRM_Utils_Array::value('years', $age);
- $values['age']['m'] = CRM_Utils_Array::value('months', $age);
+ $values['age']['y'] = $age['years'] ?? NULL;
+ $values['age']['m'] = $age['months'] ?? NULL;
}
}
* TRUE if user has all permissions, FALSE if otherwise.
*/
public static function checkUserMenuPermissions($aclPermissionedTasks, $corePermission, $menuOptions) {
- $componentName = CRM_Utils_Array::value('component', $menuOptions);
+ $componentName = $menuOptions['component'] ?? NULL;
// if component action - make sure component is enable.
if ($componentName && !in_array($componentName, CRM_Core_Config::singleton()->enableComponents)) {
// make sure user has all required permissions.
$hasAllPermissions = FALSE;
- $permissions = CRM_Utils_Array::value('permissions', $menuOptions);
+ $permissions = $menuOptions['permissions'] ?? NULL;
if (!is_array($permissions) || empty($permissions)) {
$hasAllPermissions = TRUE;
}
if (array_key_exists($fieldname, $parentResult) && is_array($parentResult[$fieldname])) {
$arrayLocation = $parentResult[$fieldname];
foreach ($stringParts as $key => $innerValue) {
- $arrayLocation = CRM_Utils_Array::value($innerValue, $arrayLocation);
+ $arrayLocation = $arrayLocation[$innerValue] ?? NULL;
}
$value = $arrayLocation;
}
]);
foreach ($activities as &$activity) {
if (!empty($activity['case_id'])) {
- $case = CRM_Utils_Array::value($activity['case_id'][0], $cases['values']);
+ $case = $cases['values'][$activity['case_id'][0]] ?? NULL;
if ($case) {
foreach ($case as $key => $value) {
if ($key != 'id') {
//correctly by doing pseudoconstant validation
// needs testing
$activityTypes = CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'validate');
- $activityName = CRM_Utils_Array::value('activity_name', $params);
+ $activityName = $params['activity_name'] ?? NULL;
$activityName = ucfirst($activityName);
- $activityLabel = CRM_Utils_Array::value('activity_label', $params);
+ $activityLabel = $params['activity_label'] ?? NULL;
if ($activityLabel) {
$activityTypes = CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'create');
}
- $activityTypeId = CRM_Utils_Array::value('activity_type_id', $params);
+ $activityTypeId = $params['activity_type_id'] ?? NULL;
if ($activityName || $activityLabel) {
$activityTypeIdInList = array_search(($activityName ? $activityName : $activityLabel), $activityTypes);
* @throws API_Exception validation errors
*/
function _civicrm_api3_attachment_parse_params($params) {
- $id = CRM_Utils_Array::value('id', $params, NULL);
+ $id = $params['id'] ?? NULL;
if ($id && !is_numeric($id)) {
throw new API_Exception("Malformed id");
}
];
$greetings = CRM_Core_PseudoConstant::greeting($filter);
- $greetingId = CRM_Utils_Array::value("{$key}{$greeting}_id", $params);
- $greetingVal = CRM_Utils_Array::value("{$key}{$greeting}", $params);
- $customGreeting = CRM_Utils_Array::value("{$key}{$greeting}_custom", $params);
+ $greetingId = $params["{$key}{$greeting}_id"] ?? NULL;
+ $greetingVal = $params["{$key}{$greeting}"] ?? NULL;
+ $customGreeting = $params["{$key}{$greeting}_custom"] ?? NULL;
if (!$greetingId && $greetingVal) {
$params["{$key}{$greeting}_id"] = CRM_Utils_Array::key($params["{$key}{$greeting}"], $greetings);
* @throws Exception
*/
function civicrm_api3_contact_proximity($params) {
- $latitude = CRM_Utils_Array::value('latitude', $params);
- $longitude = CRM_Utils_Array::value('longitude', $params);
- $distance = CRM_Utils_Array::value('distance', $params);
+ $latitude = $params['latitude'] ?? NULL;
+ $longitude = $params['longitude'] ?? NULL;
+ $distance = $params['distance'] ?? NULL;
- $unit = CRM_Utils_Array::value('unit', $params);
+ $unit = $params['unit'] ?? NULL;
// check and ensure that lat/long and distance are floats
if (
$params['financial_type_id']['api.aliases'] = ['contribution_type_id'];
$params['payment_instrument_id']['api.aliases'] = ['contribution_payment_instrument', 'payment_instrument'];
- $params['contact_id'] = CRM_Utils_Array::value('contribution_contact_id', $params);
+ $params['contact_id'] = $params['contribution_contact_id'] ?? NULL;
$params['contact_id']['api.aliases'] = ['contribution_contact_id'];
$params['is_template']['api.default'] = 0;
unset($params['contribution_contact_id']);
$input['receipt_from_name'] = CRM_Utils_Array::value('receipt_from_name', $params, $domainFromName);
$input['receipt_from_email'] = CRM_Utils_Array::value('receipt_from_email', $params, $domainFromEmail);
}
- $input['card_type_id'] = CRM_Utils_Array::value('card_type_id', $params);
- $input['pan_truncation'] = CRM_Utils_Array::value('pan_truncation', $params);
+ $input['card_type_id'] = $params['card_type_id'] ?? NULL;
+ $input['pan_truncation'] = $params['pan_truncation'] ?? NULL;
$transaction = new CRM_Core_Transaction();
return CRM_Contribute_BAO_Contribution::completeOrder($input, $ids, $objects, $transaction,
$contribution, CRM_Utils_Array::value('is_post_payment_create', $params));
// authorization from a payment processor like Paypal checkout) the lack of a qfKey will not result in a valid
// one being generated so we generate one first.
$originalRequest = $_REQUEST;
- $qfKey = CRM_Utils_Array::value('qfKey', $_REQUEST);
+ $qfKey = $_REQUEST['qfKey'] ?? NULL;
if (!$qfKey) {
$_REQUEST['qfKey'] = CRM_Core_Key::get('CRM_Core_Controller', TRUE);
}
$result[$group['name']] = [];
$groupToReturn = $toReturn['custom_group'] ? $toReturn['custom_group'] : array_keys($group);
foreach ($groupToReturn as $item) {
- $result[$group['name']][$item] = CRM_Utils_Array::value($item, $group);
+ $result[$group['name']][$item] = $group[$item] ?? NULL;
}
$result[$group['name']]['fields'] = [];
foreach ($group['fields'] as $fieldInfo) {
$field = ['value' => NULL];
$fieldToReturn = $toReturn['custom_field'] ? $toReturn['custom_field'] : array_keys($fieldInfo);
foreach ($fieldToReturn as $item) {
- $field[$item] = CRM_Utils_Array::value($item, $fieldInfo);
+ $field[$item] = $fieldInfo[$item] ?? NULL;
}
unset($field['customValue']);
if (!empty($fieldInfo['customValue'])) {
*/
function civicrm_api3_domain_get($params) {
- $params['version'] = CRM_Utils_Array::value('domain_version', $params);
+ $params['version'] = $params['domain_version'] ?? NULL;
unset($params['version']);
$bao = new CRM_Core_BAO_Domain();
];
if (!empty($values['location']['email'])) {
- $domain['domain_email'] = CRM_Utils_Array::value('email', $values['location']['email'][1]);
+ $domain['domain_email'] = $values['location']['email'][1]['email'] ?? NULL;
}
if (!empty($values['location']['phone'])) {
}
$entity = $apiRequest['entity'];
$lowercase_entity = _civicrm_api_get_entity_name_from_camel($entity);
- $subentity = CRM_Utils_Array::value('contact_type', $apiRequest['params']);
- $action = CRM_Utils_Array::value('action', $apiRequest['params']);
+ $subentity = $apiRequest['params']['contact_type'] ?? NULL;
+ $action = $apiRequest['params']['action'] ?? NULL;
$sequential = empty($apiRequest['params']['sequential']) ? 0 : 1;
$apiRequest['params']['options'] = CRM_Utils_Array::value('options', $apiRequest['params'], []);
$optionsToResolve = (array) CRM_Utils_Array::value('get_options', $apiRequest['params']['options'], []);
return civicrm_api3_create_error("The field '{$apiRequest['params']['field']}' doesn't exist.");
}
// Validate 'context' from params
- $context = CRM_Utils_Array::value('context', $apiRequest['params']);
+ $context = $apiRequest['params']['context'] ?? NULL;
CRM_Core_DAO::buildOptionsContext($context);
unset($apiRequest['params']['context'], $apiRequest['params']['field'], $apiRequest['params']['condition']);
}
// Allow caller to specify context
- $context = CRM_Utils_Array::value('get_options_context', $apiRequest['params']['options']);
+ $context = $apiRequest['params']['options']['get_options_context'] ?? NULL;
// Default to api action if it is a supported context.
if (!$context) {
- $action = CRM_Utils_Array::value('action', $apiRequest['params']);
+ $action = $apiRequest['params']['action'] ?? NULL;
$contexts = CRM_Core_DAO::buildOptionsContext();
if (isset($contexts[$action])) {
$context = $action;
}
$status = CRM_Utils_Array::value('status', $params, 'Added');
- $groupId = CRM_Utils_Array::value('group_id', $params);
+ $groupId = $params['group_id'] ?? NULL;
$values = CRM_Contact_BAO_GroupContact::getContactGroup($params['contact_id'], $status, NULL, FALSE, TRUE, FALSE, TRUE, $groupId);
return civicrm_api3_create_success($values, $params, 'GroupContact');
}
$method = CRM_Utils_Array::value('method', $params, 'API');
$status = CRM_Utils_Array::value('status', $params, $op);
- $tracking = CRM_Utils_Array::value('tracking', $params);
+ $tracking = $params['tracking'] ?? NULL;
if ($op == 'Added' || $op == 'Pending') {
$extraReturnValues = [
* @throws \CiviCRM_API3_Exception
*/
function civicrm_api3_job_process_batch_merge($params) {
- $rule_group_id = CRM_Utils_Array::value('rule_group_id', $params);
+ $rule_group_id = $params['rule_group_id'] ?? NULL;
if (!$rule_group_id) {
$rule_group_id = civicrm_api3('RuleGroup', 'getvalue', [
'contact_type' => 'Individual',
'options' => ['limit' => 1],
]);
}
- $rgid = CRM_Utils_Array::value('rgid', $params);
- $gid = CRM_Utils_Array::value('gid', $params);
+ $rgid = $params['rgid'] ?? NULL;
+ $gid = $params['gid'] ?? NULL;
$mode = CRM_Utils_Array::value('mode', $params, 'safe');
$result = CRM_Dedupe_Merger::batchMerge($rule_group_id, $gid, $mode, 1, 2, CRM_Utils_Array::value('criteria', $params, []), CRM_Utils_Array::value('check_permissions', $params), NULL, $params['search_limit']);
$get = civicrm_api3('Mailing', 'getsingle', ['id' => $params['id']]);
$newParams = [];
- $newParams['debug'] = CRM_Utils_Array::value('debug', $params);
+ $newParams['debug'] = $params['debug'] ?? NULL;
$newParams['groups']['include'] = [];
$newParams['groups']['exclude'] = [];
$newParams['mailings']['include'] = [];
$queue = $params['event_queue_id'];
$hash = $params['hash'];
$replyto = $params['replyTo'];
- $bodyTxt = CRM_Utils_Array::value('bodyTxt', $params);
- $bodyHTML = CRM_Utils_Array::value('bodyHTML', $params);
- $fullEmail = CRM_Utils_Array::value('fullEmail', $params);
+ $bodyTxt = $params['bodyTxt'] ?? NULL;
+ $bodyHTML = $params['bodyHTML'] ?? NULL;
+ $fullEmail = $params['fullEmail'] ?? NULL;
$mailing = CRM_Mailing_Event_BAO_Reply::reply($job, $queue, $hash, $replyto);
$queue = $params['event_queue_id'];
$hash = $params['hash'];
$email = $params['email'];
- $fromEmail = CRM_Utils_Array::value('fromEmail', $params);
- $params = CRM_Utils_Array::value('params', $params);
+ $fromEmail = $params['fromEmail'] ?? NULL;
+ $params = $params['params'] ?? NULL;
$forward = CRM_Mailing_Event_BAO_Forward::forward($job, $queue, $hash, $email, $fromEmail, $params);
}
$mailing = new CRM_Mailing_BAO_Mailing();
- $mailingID = CRM_Utils_Array::value('id', $params);
+ $mailingID = $params['id'] ?? NULL;
if ($mailingID) {
$mailing->id = $mailingID;
$mailing->find(TRUE);
$attachments = CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id);
$returnProperties = $mailing->getReturnProperties();
- $contactID = CRM_Utils_Array::value('contact_id', $params);
+ $contactID = $params['contact_id'] ?? NULL;
if (!$contactID) {
// If we still don't have a userID in a session because we are annon then set contactID to be 0
$contactID = empty($session->get('userID')) ? 0 : $session->get('userID');
if (!$contactID) {
$details = CRM_Utils_Token::getAnonymousTokenDetails($mailingParams, $returnProperties, TRUE, TRUE, NULL, $mailing->getFlattenedTokens());
- $details = CRM_Utils_Array::value(0, $details[0]);
+ $details = $details[0][0] ?? NULL;
}
else {
$details = CRM_Utils_Token::getTokenDetails($mailingParams, $returnProperties, TRUE, TRUE, NULL, $mailing->getFlattenedTokens());
function civicrm_api3_mailing_event_subscribe_create($params) {
$email = $params['email'];
$group_id = $params['group_id'];
- $contact_id = CRM_Utils_Array::value('contact_id', $params);
+ $contact_id = $params['contact_id'] ?? NULL;
$group = new CRM_Contact_DAO_Group();
$group->is_active = 1;
function civicrm_api3_membership_get($params) {
$activeOnly = $membershipTypeId = $membershipType = NULL;
- $contactID = CRM_Utils_Array::value('contact_id', $params);
+ $contactID = $params['contact_id'] ?? NULL;
if (!empty($params['filters']) && is_array($params['filters']) && isset($params['filters']['is_current'])) {
$activeOnly = $params['filters']['is_current'];
unset($params['filters']['is_current']);
// populating relationship type name.
$relationshipType = new CRM_Contact_BAO_RelationshipType();
- $relationshipType->id = CRM_Utils_Array::value('relationship_type_id', $membershipType);
+ $relationshipType->id = $membershipType['relationship_type_id'] ?? NULL;
if ($relationshipType->find(TRUE)) {
$membershipValues[$membershipId]['relationship_name'] = $relationshipType->name_a_b;
}
civicrm_api3_verify_mandatory($params, NULL, ['id']);
//don't allow duplicate names.
- $name = CRM_Utils_Array::value('name', $params);
+ $name = $params['name'] ?? NULL;
if ($name) {
$status = new CRM_Member_DAO_MembershipStatus();
$status->name = $params['name'];
civicrm_api3_verify_one_mandatory($params, NULL, ['line_items', 'total_amount']);
$entity = NULL;
$entityIds = [];
- $contributionStatus = CRM_Utils_Array::value('contribution_status_id', $params);
+ $contributionStatus = $params['contribution_status_id'] ?? NULL;
if ($contributionStatus !== 'Pending' && 'Pending' !== CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $contributionStatus)) {
CRM_Core_Error::deprecatedFunctionWarning("Creating a Order with a status other than pending is deprecated. Currently empty defaults to 'Completed' so as a transition not passing in 'Pending' is deprecated. You can chain payment creation e.g civicrm_api3('Order', 'create', ['blah' => 'blah', 'contribution_status_id' => 'Pending', 'api.Payment.create => ['total_amount' => 5]]");
}
$financialTrxn = [];
$limit = '';
if (isset($params['options']) && !empty($params['options']['limit'])) {
- $limit = CRM_Utils_Array::value('limit', $params['options']);
+ $limit = $params['options']['limit'] ?? NULL;
}
$params['options']['limit'] = 0;
if (isset($params['trxn_id'])) {
* @throws \API_Exception
*/
function civicrm_api3_setting_getoptions($params) {
- $domainId = CRM_Utils_Array::value('domain_id', $params);
+ $domainId = $params['domain_id'] ?? NULL;
$specs = \Civi\Core\SettingsMetadata::getMetadata(['name' => $params['field']], $domainId, TRUE);
if (empty($specs[$params['field']]) || !is_array(CRM_Utils_Array::value('options', $specs[$params['field']]))) {
}
}
$options = array_merge($options, $additional_options);
- $sort = CRM_Utils_Array::value('sort', $options, NULL);
- $offset = CRM_Utils_Array::value('offset', $options, NULL);
- $limit = CRM_Utils_Array::value('limit', $options, NULL);
- $smartGroupCache = CRM_Utils_Array::value('smartGroupCache', $params);
+ $sort = $options['sort'] ?? NULL;
+ $offset = $options['offset'] ?? NULL;
+ $limit = $options['limit'] ?? NULL;
+ $smartGroupCache = $params['smartGroupCache'] ?? NULL;
if ($getCount) {
$limit = NULL;