CRM/Admin - Refactor unnecessary uses of CRM_Utils_Array::value
authorcolemanw <coleman@civicrm.org>
Fri, 13 Oct 2023 23:43:02 +0000 (19:43 -0400)
committercolemanw <coleman@civicrm.org>
Sat, 14 Oct 2023 03:22:08 +0000 (23:22 -0400)
CRM/Admin/Form/MailSettings.php
CRM/Admin/Form/PaymentProcessorType.php
CRM/Admin/Form/Preferences/Contribute.php
CRM/Admin/Form/RelationshipType.php

index acdc5744da432a3b96cc925146dd96aa2c8e537a..833c0de1375378f8488bf488b56d1f6f23cc36a6 100644 (file)
@@ -211,7 +211,7 @@ class CRM_Admin_Form_MailSettings extends CRM_Admin_Form {
         'is_contact_creation_disabled_if_no_match',
         'is_active',
       ])) {
-        $params[$f] = CRM_Utils_Array::value($f, $formValues, FALSE);
+        $params[$f] = $formValues[$f] ?? FALSE;
       }
       else {
         $params[$f] = $formValues[$f] ?? NULL;
index 2259920ef8a37fa89508eaa93b6ca34215b8c600..8543723e85a94ab95ffc00196f806c4c12116f23 100644 (file)
@@ -146,7 +146,7 @@ class CRM_Admin_Form_PaymentProcessorType extends CRM_Admin_Form {
     $attributes = CRM_Core_DAO::getAttribute('CRM_Financial_DAO_PaymentProcessorType');
 
     foreach ($this->_fields as $field) {
-      $required = CRM_Utils_Array::value('required', $field, FALSE);
+      $required = $field['required'] ?? FALSE;
       $this->add('text', $field['name'],
         $field['label'], $attributes['name'], $required
       );
@@ -210,9 +210,9 @@ UPDATE civicrm_payment_processor SET is_default = 0";
     $dao = new CRM_Financial_DAO_PaymentProcessorType();
 
     $dao->id = $this->_id;
-    $dao->is_default = CRM_Utils_Array::value('is_default', $values, 0);
-    $dao->is_active = CRM_Utils_Array::value('is_active', $values, 0);
-    $dao->is_recur = CRM_Utils_Array::value('is_recur', $values, 0);
+    $dao->is_default = $values['is_default'] ?? 0;
+    $dao->is_active = $values['is_active'] ?? 0;
+    $dao->is_recur = $values['is_recur'] ?? 0;
 
     $dao->name = $values['name'];
     $dao->description = $values['description'];
index 7729a1f170ed00baede99e3252863bcd03390eb7..e6182123ee5135e77c49d6602042827b55587e09 100644 (file)
@@ -167,7 +167,7 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences {
     // too. This means that saving from api will not have the desired core effect.
     // but we should fix that elsewhere - ie. stop abusing the settings
     // and fix the code repetition associated with invoicing
-    $invoiceParams['invoicing'] = CRM_Utils_Array::value('invoicing', $params, 0);
+    $invoiceParams['invoicing'] = $params['invoicing'] ?? 0;
     Civi::settings()->set('contribution_invoice_settings', $invoiceParams);
     parent::postProcess();
   }
index ce43206171550aec7e192bf3e5fdf03968528fae..c3c07573ddc3ad4bda7d3f8157b726cdcbf522a1 100644 (file)
@@ -141,7 +141,7 @@ class CRM_Admin_Form_RelationshipType extends CRM_Admin_Form {
     else {
       // store the submitted values in an array
       $params = $this->exportValues();
-      $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
+      $params['is_active'] = $params['is_active'] ?? FALSE;
 
       if ($this->_action & CRM_Core_Action::UPDATE) {
         $params['id'] = $this->_id;