From: colemanw Date: Fri, 13 Oct 2023 23:45:24 +0000 (-0400) Subject: CRM/Misc - Refactor unnecessary uses of CRM_Utils_Array::value X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f5d691d34b06f9d09ba392a4e323b50a548c9b1f;p=civicrm-core.git CRM/Misc - Refactor unnecessary uses of CRM_Utils_Array::value --- diff --git a/CRM/ACL/Form/ACL.php b/CRM/ACL/Form/ACL.php index b4f52a7c74..5f5c5b88a5 100644 --- a/CRM/ACL/Form/ACL.php +++ b/CRM/ACL/Form/ACL.php @@ -256,7 +256,7 @@ class CRM_ACL_Form_ACL extends CRM_Admin_Form { } else { $params = $this->controller->exportValues($this->_name); - $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE); + $params['is_active'] = $params['is_active'] ?? FALSE; $params['entity_table'] = 'civicrm_acl_role'; // Figure out which type of object we're permissioning on and set object_table and object_id. diff --git a/CRM/Badge/BAO/Layout.php b/CRM/Badge/BAO/Layout.php index c146c3a49c..e7443c3ef4 100644 --- a/CRM/Badge/BAO/Layout.php +++ b/CRM/Badge/BAO/Layout.php @@ -50,9 +50,9 @@ class CRM_Badge_BAO_Layout extends CRM_Core_DAO_PrintLabel { * @return object */ public static function create(&$params) { - $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE); - $params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE); - $params['is_reserved'] = CRM_Utils_Array::value('is_reserved', $params, FALSE); + $params['is_active'] = $params['is_active'] ?? FALSE; + $params['is_default'] = $params['is_default'] ?? FALSE; + $params['is_reserved'] = $params['is_reserved'] ?? FALSE; $params['label_type_id'] = CRM_Core_PseudoConstant::getKey('CRM_Core_DAO_PrintLabel', 'label_type_id', 'Event Badge'); diff --git a/CRM/Dedupe/MergeHandler.php b/CRM/Dedupe/MergeHandler.php index 79c296fdcc..cf64201bcd 100644 --- a/CRM/Dedupe/MergeHandler.php +++ b/CRM/Dedupe/MergeHandler.php @@ -398,7 +398,7 @@ class CRM_Dedupe_MergeHandler { foreach ($block as $blkCount => $values) { $otherBlockId = $migrationInfo['other_details']['location_blocks'][$name][$blkCount]['id'] ?? NULL; - $mainBlockId = CRM_Utils_Array::value('mainContactBlockId', $migrationInfo['location_blocks'][$name][$blkCount], 0); + $mainBlockId = $migrationInfo['location_blocks'][$name][$blkCount]['mainContactBlockId'] ?? 0; if (!$otherBlockId) { continue; } diff --git a/CRM/Friend/BAO/Friend.php b/CRM/Friend/BAO/Friend.php index 6e97730cce..2a0945ea4d 100644 --- a/CRM/Friend/BAO/Friend.php +++ b/CRM/Friend/BAO/Friend.php @@ -320,7 +320,7 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend { public static function addTellAFriend(&$params) { $friendDAO = new CRM_Friend_DAO_Friend(); $friendDAO->copyValues($params); - $friendDAO->is_active = CRM_Utils_Array::value('is_active', $params, FALSE); + $friendDAO->is_active = $params['is_active'] ?? FALSE; $friendDAO->save(); return $friendDAO; diff --git a/CRM/Friend/Form/Contribute.php b/CRM/Friend/Form/Contribute.php index 0a85b96a1a..5aa5cbcdd7 100644 --- a/CRM/Friend/Form/Contribute.php +++ b/CRM/Friend/Form/Contribute.php @@ -95,7 +95,7 @@ class CRM_Friend_Form_Contribute extends CRM_Contribute_Form_ContributionPage { $formValues['entity_table'] = 'civicrm_contribution_page'; $formValues['entity_id'] = $this->_id; $formValues['title'] = $formValues['tf_title']; - $formValues['is_active'] = CRM_Utils_Array::value('tf_is_active', $formValues, FALSE); + $formValues['is_active'] = $formValues['tf_is_active'] ?? FALSE; $formValues['thankyou_title'] = $formValues['tf_thankyou_title'] ?? NULL; $formValues['thankyou_text'] = $formValues['tf_thankyou_text'] ?? NULL; diff --git a/CRM/Friend/Form/Event.php b/CRM/Friend/Form/Event.php index cad46dde25..f87e0c68d5 100644 --- a/CRM/Friend/Form/Event.php +++ b/CRM/Friend/Form/Event.php @@ -103,7 +103,7 @@ class CRM_Friend_Form_Event extends CRM_Event_Form_ManageEvent { $formValues['entity_table'] = 'civicrm_event'; $formValues['entity_id'] = $this->_id; $formValues['title'] = $formValues['tf_title']; - $formValues['is_active'] = CRM_Utils_Array::value('tf_is_active', $formValues, FALSE); + $formValues['is_active'] = $formValues['tf_is_active'] ?? FALSE; $formValues['thankyou_title'] = $formValues['tf_thankyou_title'] ?? NULL; $formValues['thankyou_text'] = $formValues['tf_thankyou_text'] ?? NULL; diff --git a/CRM/Group/Form/Edit.php b/CRM/Group/Form/Edit.php index 772cda0786..e85af4c327 100644 --- a/CRM/Group/Form/Edit.php +++ b/CRM/Group/Form/Edit.php @@ -356,8 +356,8 @@ WHERE title = %1 $params['group_type'] = []; } - $params['is_reserved'] = CRM_Utils_Array::value('is_reserved', $params, FALSE); - $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE); + $params['is_reserved'] = $params['is_reserved'] ?? FALSE; + $params['is_active'] = $params['is_active'] ?? FALSE; $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $this->_id, 'Group' diff --git a/CRM/PCP/Form/Contribute.php b/CRM/PCP/Form/Contribute.php index 890ffeb13e..33ba099355 100644 --- a/CRM/PCP/Form/Contribute.php +++ b/CRM/PCP/Form/Contribute.php @@ -144,9 +144,9 @@ class CRM_PCP_Form_Contribute extends CRM_Contribute_Form_ContributionPage { $dao->entity_id = $this->_id; $dao->find(TRUE); $params['id'] = $dao->id; - $params['is_active'] = CRM_Utils_Array::value('pcp_active', $params, FALSE); - $params['is_approval_needed'] = CRM_Utils_Array::value('is_approval_needed', $params, FALSE); - $params['is_tellfriend_enabled'] = CRM_Utils_Array::value('is_tellfriend_enabled', $params, FALSE); + $params['is_active'] = $params['pcp_active'] ?? FALSE; + $params['is_approval_needed'] = $params['is_approval_needed'] ?? FALSE; + $params['is_tellfriend_enabled'] = $params['is_tellfriend_enabled'] ?? FALSE; CRM_PCP_BAO_PCPBlock::writeRecord($params); diff --git a/CRM/PCP/Form/Event.php b/CRM/PCP/Form/Event.php index 636968f8a0..e15af602f4 100644 --- a/CRM/PCP/Form/Event.php +++ b/CRM/PCP/Form/Event.php @@ -181,9 +181,9 @@ class CRM_PCP_Form_Event extends CRM_Event_Form_ManageEvent { $dao->entity_id = $this->_id; $dao->find(TRUE); $params['id'] = $dao->id; - $params['is_active'] = CRM_Utils_Array::value('pcp_active', $params, FALSE); - $params['is_approval_needed'] = CRM_Utils_Array::value('is_approval_needed', $params, FALSE); - $params['is_tellfriend_enabled'] = CRM_Utils_Array::value('is_tellfriend_enabled', $params, FALSE); + $params['is_active'] = $params['pcp_active'] ?? FALSE; + $params['is_approval_needed'] = $params['is_approval_needed'] ?? FALSE; + $params['is_tellfriend_enabled'] = $params['is_tellfriend_enabled'] ?? FALSE; CRM_PCP_BAO_PCPBlock::writeRecord($params); diff --git a/CRM/Profile/Page/MultipleRecordFieldsListing.php b/CRM/Profile/Page/MultipleRecordFieldsListing.php index 00e507f139..0a2454c1c6 100644 --- a/CRM/Profile/Page/MultipleRecordFieldsListing.php +++ b/CRM/Profile/Page/MultipleRecordFieldsListing.php @@ -228,7 +228,7 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { if ($returnValues['data_type'] == 'Date') { $dateFields[$fieldIDs[$key]] = 1; $actualPHPFormats = CRM_Utils_Date::datePluginToPHPFormats(); - $dateFormat = (array) CRM_Utils_Array::value($returnValues['date_format'], $actualPHPFormats); + $dateFormat = (array) ($actualPHPFormats[$returnValues['date_format']] ?? []); $timeFormat = $returnValues['time_format'] ?? NULL; } diff --git a/CRM/Queue/Runner.php b/CRM/Queue/Runner.php index f89e319127..2be2ceed64 100644 --- a/CRM/Queue/Runner.php +++ b/CRM/Queue/Runner.php @@ -119,7 +119,7 @@ class CRM_Queue_Runner { $this->title = CRM_Utils_Array::value('title', $runnerSpec, ts('Queue Runner')); $this->queue = $runnerSpec['queue']; $this->errorMode = CRM_Utils_Array::value('errorMode', $runnerSpec, $this->pickErrorMode($this->queue)); - $this->isMinimal = CRM_Utils_Array::value('isMinimal', $runnerSpec, FALSE); + $this->isMinimal = $runnerSpec['isMinimal'] ?? FALSE; $this->onEnd = $runnerSpec['onEnd'] ?? NULL; $this->onEndUrl = $runnerSpec['onEndUrl'] ?? NULL; $this->pathPrefix = CRM_Utils_Array::value('pathPrefix', $runnerSpec, 'civicrm/queue'); diff --git a/CRM/SMS/Form/Provider.php b/CRM/SMS/Form/Provider.php index 1f5e2313e1..602f0e6847 100644 --- a/CRM/SMS/Form/Provider.php +++ b/CRM/SMS/Form/Provider.php @@ -157,8 +157,8 @@ class CRM_SMS_Form_Provider extends CRM_Core_Form { } $recData = $values = $this->controller->exportValues($this->_name); - $recData['is_active'] = CRM_Utils_Array::value('is_active', $recData, 0); - $recData['is_default'] = CRM_Utils_Array::value('is_default', $recData, 0); + $recData['is_active'] = $recData['is_active'] ?? 0; + $recData['is_default'] = $recData['is_default'] ?? 0; if ($this->_action && (CRM_Core_Action::UPDATE || CRM_Core_Action::ADD)) { if ($this->_id) { diff --git a/CRM/UF/Form/Field.php b/CRM/UF/Form/Field.php index 5e9e87a229..053e61c13a 100644 --- a/CRM/UF/Form/Field.php +++ b/CRM/UF/Form/Field.php @@ -725,11 +725,11 @@ class CRM_UF_Form_Field extends CRM_Core_Form { * list of errors to be posted back to the form */ public static function formRule($fields, $files, $self) { - $is_required = CRM_Utils_Array::value('is_required', $fields, FALSE); - $is_registration = CRM_Utils_Array::value('is_registration', $fields, FALSE); - $is_view = CRM_Utils_Array::value('is_view', $fields, FALSE); - $in_selector = CRM_Utils_Array::value('in_selector', $fields, FALSE); - $is_active = CRM_Utils_Array::value('is_active', $fields, FALSE); + $is_required = $fields['is_required'] ?? FALSE; + $is_registration = $fields['is_registration'] ?? FALSE; + $is_view = $fields['is_view'] ?? FALSE; + $in_selector = $fields['in_selector'] ?? FALSE; + $is_active = $fields['is_active'] ?? FALSE; $errors = []; if ($is_view && $is_registration) { diff --git a/CRM/Upgrade/Incremental/php/FiveFour.php b/CRM/Upgrade/Incremental/php/FiveFour.php index b327366a14..07ce677392 100644 --- a/CRM/Upgrade/Incremental/php/FiveFour.php +++ b/CRM/Upgrade/Incremental/php/FiveFour.php @@ -69,7 +69,7 @@ class CRM_Upgrade_Incremental_php_FiveFour extends CRM_Upgrade_Incremental_Base 'option_group_id' => 'activity_default_assignee', 'name' => $option['name'], 'label' => $option['label'], - 'is_default' => CRM_Utils_Array::value('is_default', $option, 0), + 'is_default' => $option['is_default'] ?? 0, 'is_active' => TRUE, ]); }