CRM/Misc - Refactor unnecessary uses of CRM_Utils_Array::value
authorcolemanw <coleman@civicrm.org>
Fri, 13 Oct 2023 23:45:24 +0000 (19:45 -0400)
committercolemanw <coleman@civicrm.org>
Sat, 14 Oct 2023 03:28:46 +0000 (23:28 -0400)
14 files changed:
CRM/ACL/Form/ACL.php
CRM/Badge/BAO/Layout.php
CRM/Dedupe/MergeHandler.php
CRM/Friend/BAO/Friend.php
CRM/Friend/Form/Contribute.php
CRM/Friend/Form/Event.php
CRM/Group/Form/Edit.php
CRM/PCP/Form/Contribute.php
CRM/PCP/Form/Event.php
CRM/Profile/Page/MultipleRecordFieldsListing.php
CRM/Queue/Runner.php
CRM/SMS/Form/Provider.php
CRM/UF/Form/Field.php
CRM/Upgrade/Incremental/php/FiveFour.php

index b4f52a7c746af7d61d21f8c6585d191f82fce5c4..5f5c5b88a5e254b42f0149e8a4c5009519c1e68a 100644 (file)
@@ -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.
index c146c3a49c18a95def1ab0aefb261cfaaf559d9c..e7443c3ef43fa951b67644b81f31a206815753c0 100644 (file)
@@ -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');
 
index 79c296fdccb6050ee011d02177b6f0c9425828cb..cf64201bcdb4e0dcdb62335d65e4fc44deac5db2 100644 (file)
@@ -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;
           }
index 6e97730cce8118734d155e3577a7c80618e4070c..2a0945ea4d9af95f34d92c9966c1bd9099f64395 100644 (file)
@@ -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;
index 0a85b96a1adab7d164be8063bdde1aca5e988941..5aa5cbcdd7ba702a190b0d28a2860d990834a00c 100644 (file)
@@ -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;
 
index cad46dde25c1a11511e9fecc8a5beb7a2b197bbe..f87e0c68d54f73d3aed1c3f82b480a034ca45cf7 100644 (file)
@@ -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;
 
index 772cda0786c567ab17e99e6c79b1704198b2f1e7..e85af4c327d9d11d745c321b26058b2a7c884abb 100644 (file)
@@ -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'
index 890ffeb13e1137e50a80448cb8cc2ddd2b5a25f2..33ba099355db22d49d98d48f57954d36847bd3c3 100644 (file)
@@ -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);
 
index 636968f8a05d9c5866356d62838c17c072e9a868..e15af602f4fabe8ff50b08671790171c23f4533d 100644 (file)
@@ -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);
 
index 00e507f139cd5e7a880c449462d717071944ede0..0a2454c1c66df1684241ccb8cb09c4a2e4b4b0d9 100644 (file)
@@ -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;
         }
 
index f89e319127774cdd9a42c54b3e0ce328aafbf827..2be2ceed648f9aa4625406511acf2ed1f10a5e96 100644 (file)
@@ -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');
index 1f5e2313e1258c2527c2b47d4631020a4ff943ea..602f0e68475dfdec6e5f9553a8e6912e57406c48 100644 (file)
@@ -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) {
index 5e9e87a22987eac049da19865636666531c79e3c..053e61c13a26e70b620293d71cda15fe6c8e1429 100644 (file)
@@ -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) {
index b327366a14ec8f1d2d39a6776dfad1a8942806af..07ce677392de6a3cf6f1f441b88a580787d75dc7 100644 (file)
@@ -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,
       ]);
     }