From: colemanw Date: Fri, 13 Oct 2023 23:40:31 +0000 (-0400) Subject: CRM/Core - Refactor unnecessary uses of CRM_Utils_Array::value X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=d2cf0dc15701acc4784b209dfd809b9e6feb42ac;p=civicrm-core.git CRM/Core - Refactor unnecessary uses of CRM_Utils_Array::value --- diff --git a/CRM/Core/BAO/Address.php b/CRM/Core/BAO/Address.php index d7391167e7..0d0fe6b21d 100644 --- a/CRM/Core/BAO/Address.php +++ b/CRM/Core/BAO/Address.php @@ -1312,7 +1312,7 @@ SELECT is_primary, } CRM_Core_BAO_Block::sortPrimaryFirst($params['address']); - $updateBlankLocInfo = CRM_Utils_Array::value('updateBlankLocInfo', $params, FALSE); + $updateBlankLocInfo = $params['updateBlankLocInfo'] ?? FALSE; $contactId = $params['contact_id']; //get all the addresses for this contact $addresses = self::allAddress($contactId); diff --git a/CRM/Core/BAO/Block.php b/CRM/Core/BAO/Block.php index bd80441e14..fe5df456d3 100644 --- a/CRM/Core/BAO/Block.php +++ b/CRM/Core/BAO/Block.php @@ -208,8 +208,8 @@ class CRM_Core_BAO_Block { $contactId = $params['contact_id']; - $updateBlankLocInfo = CRM_Utils_Array::value('updateBlankLocInfo', $params, FALSE); - $isIdSet = CRM_Utils_Array::value('isIdSet', $params[$blockName], FALSE); + $updateBlankLocInfo = $params['updateBlankLocInfo'] ?? FALSE; + $isIdSet = $params[$blockName]['isIdSet'] ?? FALSE; //get existing block ids. $blockIds = self::getBlockIds($blockName, $contactId, $entityElements); diff --git a/CRM/Core/BAO/MailSettings.php b/CRM/Core/BAO/MailSettings.php index 1519394d03..e9c1a5d245 100644 --- a/CRM/Core/BAO/MailSettings.php +++ b/CRM/Core/BAO/MailSettings.php @@ -129,8 +129,8 @@ class CRM_Core_BAO_MailSettings extends CRM_Core_DAO_MailSettings { } if (empty($params['id'])) { - $params['is_ssl'] = CRM_Utils_Array::value('is_ssl', $params, FALSE); - $params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE); + $params['is_ssl'] = $params['is_ssl'] ?? FALSE; + $params['is_default'] = $params['is_default'] ?? FALSE; } //handle is_default. diff --git a/CRM/Core/BAO/Navigation.php b/CRM/Core/BAO/Navigation.php index 5357b6f7d4..ad053d8c87 100644 --- a/CRM/Core/BAO/Navigation.php +++ b/CRM/Core/BAO/Navigation.php @@ -76,8 +76,8 @@ class CRM_Core_BAO_Navigation extends CRM_Core_DAO_Navigation { public static function add(&$params) { $navigation = new CRM_Core_DAO_Navigation(); if (empty($params['id'])) { - $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE); - $params['has_separator'] = CRM_Utils_Array::value('has_separator', $params, FALSE); + $params['is_active'] = $params['is_active'] ?? FALSE; + $params['has_separator'] = $params['has_separator'] ?? FALSE; $params['domain_id'] = CRM_Utils_Array::value('domain_id', $params, CRM_Core_Config::domainID()); } diff --git a/CRM/Core/BAO/UFField.php b/CRM/Core/BAO/UFField.php index 88ef83cfe1..0212831e83 100644 --- a/CRM/Core/BAO/UFField.php +++ b/CRM/Core/BAO/UFField.php @@ -248,7 +248,7 @@ WHERE cf.id IN (" . $customFieldIds . ") AND is_multiple = 1 LIMIT 0,1"; $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFField', !empty($params['id']) ? $params['id'] : $params['field_id'], 'weight', 'id'); } $fieldValues = ['uf_group_id' => !empty($params['uf_group_id']) ? $params['uf_group_id'] : $params['group_id']]; - return CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_UFField', $oldWeight, CRM_Utils_Array::value('weight', $params, 0), $fieldValues); + return CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_UFField', $oldWeight, $params['weight'] ?? 0, $fieldValues); } /** diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index 645dfcb6d3..fae355c2e7 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -1808,7 +1808,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $view = $field['is_view']; $required = ($mode == CRM_Profile_Form::MODE_SEARCH) ? FALSE : $field['is_required']; $search = $mode == CRM_Profile_Form::MODE_SEARCH; - $isShared = CRM_Utils_Array::value('is_shared', $field, 0); + $isShared = $field['is_shared'] ?? 0; // do not display view fields in drupal registration form // CRM-4632 @@ -1958,7 +1958,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) ], $required); } elseif ($fieldName === 'contact_sub_type') { - $gId = $form->get('gid') ? $form->get('gid') : CRM_Utils_Array::value('group_id', $field); + $gId = $form->get('gid') ?: $field['group_id'] ?? NULL; if ($usedFor == 'onbehalf') { $profileType = 'Organization'; } @@ -1992,7 +1992,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } elseif (in_array($fieldName, CRM_Contact_BAO_Contact::$_greetingTypes)) { // Get contact type for greeting selector - $gId = $form->get('gid') ?: CRM_Utils_Array::value('group_id', $field); + $gId = $form->get('gid') ?: $field['group_id'] ?? NULL; $profileType = CRM_Core_BAO_UFField::getProfileType($gId, TRUE, FALSE, TRUE); if (!$profileType || in_array($profileType, ['Contact', 'Contribution', 'Participant', 'Membership'])) { diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 66a1622f2a..0cffa991c2 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -789,7 +789,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $this->submitOnce = TRUE; } - $attrs = ['class' => 'crm-form-submit'] + (array) CRM_Utils_Array::value('js', $button); + $attrs = ['class' => 'crm-form-submit'] + ($button['js'] ?? []); // A lot of forms use the hacky method of looking at // `$params['button name']` (dating back to them being inputs with a @@ -1844,7 +1844,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { } if ($context == 'search') { $widget = $widget == 'Select2' ? $widget : 'Select'; - $props['multiple'] = CRM_Utils_Array::value('multiple', $props, TRUE); + $props['multiple'] = $props['multiple'] ?? TRUE; } elseif (!empty($fieldSpec['serialize'])) { $props['multiple'] = TRUE; diff --git a/CRM/Core/OptionValue.php b/CRM/Core/OptionValue.php index 95662e6bd4..89f45a28da 100644 --- a/CRM/Core/OptionValue.php +++ b/CRM/Core/OptionValue.php @@ -181,7 +181,7 @@ class CRM_Core_OptionValue { * */ public static function addOptionValue(&$params, $optionGroupName, $action, $optionValueID) { - $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE); + $params['is_active'] = $params['is_active'] ?? FALSE; // checking if the group name with the given id or name (in $groupParams) exists $groupParams = ['name' => $optionGroupName, 'is_active' => 1]; $optionGroup = CRM_Core_BAO_OptionGroup::retrieve($groupParams, $defaults); diff --git a/CRM/Core/Page/Redirect.php b/CRM/Core/Page/Redirect.php index 4f0b83dde4..3977e5ad33 100644 --- a/CRM/Core/Page/Redirect.php +++ b/CRM/Core/Page/Redirect.php @@ -55,7 +55,7 @@ class CRM_Core_Page_Redirect extends CRM_Core_Page { $urlParts = parse_url($urlString); $url = CRM_Utils_System::url( $urlParts['path'], - CRM_Utils_Array::value('query', $urlParts, NULL), + $urlParts['query'] ?? NULL, $absolute, CRM_Utils_Array::value('fragment', $urlParts, NULL) ); diff --git a/CRM/Core/PseudoConstant.php b/CRM/Core/PseudoConstant.php index 4a86234f1f..34c9161568 100644 --- a/CRM/Core/PseudoConstant.php +++ b/CRM/Core/PseudoConstant.php @@ -496,12 +496,12 @@ class CRM_Core_PseudoConstant { */ public static function &activityType() { $args = func_get_args(); - $all = CRM_Utils_Array::value(0, $args, TRUE); - $includeCaseActivities = CRM_Utils_Array::value(1, $args, FALSE); - $reset = CRM_Utils_Array::value(2, $args, FALSE); - $returnColumn = CRM_Utils_Array::value(3, $args, 'label'); - $includeCampaignActivities = CRM_Utils_Array::value(4, $args, FALSE); - $onlyComponentActivities = CRM_Utils_Array::value(5, $args, FALSE); + $all = $args[0] ?? TRUE; + $includeCaseActivities = $args[1] ?? FALSE; + $reset = $args[2] ?? FALSE; + $returnColumn = $args[3] ?? 'label'; + $includeCampaignActivities = $args[4] ?? FALSE; + $onlyComponentActivities = $args[5] ?? FALSE; $index = (int) $all . '_' . $returnColumn . '_' . (int) $includeCaseActivities; $index .= '_' . (int) $includeCampaignActivities; $index .= '_' . (int) $onlyComponentActivities;