From e07e63963ec4128174520c5cb90c48eae1fcaeca Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Thu, 24 Nov 2022 20:39:12 +0000 Subject: [PATCH] Convert CRM_Utils_Array::value in Event/Form/Confirm --- CRM/Event/Form/Registration/Confirm.php | 48 +++++++++++-------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/CRM/Event/Form/Registration/Confirm.php b/CRM/Event/Form/Registration/Confirm.php index ead27e9fd3..7501004275 100644 --- a/CRM/Event/Form/Registration/Confirm.php +++ b/CRM/Event/Form/Registration/Confirm.php @@ -74,7 +74,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { $this->_params[0]['invoiceID'] = $this->get('invoiceID'); } $this->assign('defaultRole', FALSE); - if (CRM_Utils_Array::value('defaultRole', $this->_params[0]) == 1) { + if (($this->_params[0]['defaultRole'] ?? NULL) == 1) { $this->assign('defaultRole', TRUE); } @@ -114,7 +114,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { $rfp = CRM_Utils_Request::retrieve('rfp', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET'); //we lost rfp in case of additional participant. So set it explicitly. - if ($rfp || CRM_Utils_Array::value('additional_participants', $this->_params[0], FALSE)) { + if ($rfp || ($this->_params[0]['additional_participants'] ?? FALSE)) { if (!empty($this->_paymentProcessor) && $this->_paymentProcessor['object']->supports('preApproval')) { $preApprovalParams = $this->_paymentProcessor['object']->getPreApprovalDetails($this->get('pre_approval_parameters')); $params = array_merge($this->_params, $preApprovalParams); @@ -226,7 +226,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { } $this->_amount[$k]['label'] = preg_replace('//', '', $v['amount_level']) . ' - ' . $append; - $this->_part[$k]['info'] = CRM_Utils_Array::value('first_name', $v) . ' ' . CRM_Utils_Array::value('last_name', $v); + $this->_part[$k]['info'] = ($v['first_name'] ?? '') . ' ' . ($v['last_name'] ?? ''); if (empty($v['first_name'])) { $this->_part[$k]['info'] = $append; } @@ -339,7 +339,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { */ public static function formRule($fields, $files, $self) { $errors = []; - $eventFull = CRM_Event_BAO_Participant::eventFull($self->_eventId, FALSE, CRM_Utils_Array::value('has_waitlist', $self->_values['event'])); + $eventFull = CRM_Event_BAO_Participant::eventFull($self->_eventId, FALSE, $self->_values['event']['has_waitlist'] ?? FALSE); if ($eventFull && empty($self->_allowConfirmation)) { if (empty($self->_allowWaitlist)) { CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/register', "reset=1&id={$self->_eventId}", FALSE, NULL, FALSE, TRUE)); @@ -387,9 +387,9 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { // and fix the fee level if (!empty($this->_params[0]['discount']) && !empty($this->_params[0]['discount']['applied'])) { foreach ($this->_params as $k => $v) { - if (CRM_Utils_Array::value('amount', $this->_params[$k]) > 0 && !empty($this->_params[$k]['discountAmount'])) { + if (($this->_params[$k]['amount'] ?? NULL) > 0 && !empty($this->_params[$k]['discountAmount'])) { $this->_params[$k]['amount'] -= $this->_params[$k]['discountAmount']; - $this->_params[$k]['amount_level'] .= CRM_Utils_Array::value('discountMessage', $this->_params[$k]); + $this->_params[$k]['amount_level'] .= ($this->_params[$k]['discountMessage'] ?? NULL); } } $this->set('params', $this->_params); @@ -472,9 +472,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { } $value['description'] = ts('Online Event Registration') . ': ' . $this->_values['event']['title']; - $value['accountingCode'] = CRM_Utils_Array::value('accountingCode', - $this->_values['event'] - ); + $value['accountingCode'] = $this->_values['event']['accountingCode'] ?? NULL; $pending = FALSE; if ($this->_allowWaitlist || $this->_requireApproval) { @@ -594,10 +592,10 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { !$this->_allowWaitlist && !$this->_requireApproval ) { // transactionID & receive date required while building email template - $this->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $value)); - $this->assign('receive_date', CRM_Utils_Date::mysqlToIso(CRM_Utils_Array::value('receive_date', $value))); - $this->set('receiveDate', CRM_Utils_Date::mysqlToIso(CRM_Utils_Array::value('receive_date', $value))); - $this->set('trxnId', CRM_Utils_Array::value('trxn_id', $value)); + $this->assign('trxn_id', $value['trxn_id'] ?? NULL); + $this->assign('receive_date', CRM_Utils_Date::mysqlToIso($value['receive_date'] ?? NULL)); + $this->set('receiveDate', CRM_Utils_Date::mysqlToIso($value['receive_date'] ?? NULL)); + $this->set('trxnId', $value['trxn_id'] ?? NULL); } } @@ -649,7 +647,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { if ($value == 'skip') { continue; } - if ($entityId = CRM_Utils_Array::value($key, $allParticipantIds)) { + if ($entityId = $allParticipantIds[$key] ?? NULL) { // do cleanup line items if participant re-walking wizard. if ($this->_allowConfirmation) { CRM_Price_BAO_LineItem::deleteLineItems($entityId, $entityTable); @@ -662,7 +660,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { if (isset($line['tax_amount']) && isset($line['tax_rate'])) { $totalTaxAmount = $line['tax_amount'] + $totalTaxAmount; if (isset($dataArray[$line['tax_rate']])) { - $dataArray[$line['tax_rate']] = $dataArray[$line['tax_rate']] + CRM_Utils_Array::value('tax_amount', $line); + $dataArray[$line['tax_rate']] = $dataArray[$line['tax_rate']] + ($line['tax_amount'] ?? 0); } else { $dataArray[$line['tax_rate']] = $line['tax_amount'] ?? NULL; @@ -753,7 +751,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { if (!empty($this->_lineItem)) { $lineItems = $this->_lineItem; $lineItem = []; - if ($lineItemValue = CRM_Utils_Array::value($participantNum, $lineItems)) { + if ($lineItemValue = ($lineItems[$participantNum] ?? NULL)) { $lineItem[] = $lineItemValue; } $params[$participantNum]['lineItem'] = $lineItem; @@ -850,7 +848,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { if ($this->_lineItem) { $lineItems = $this->_lineItem; $lineItem = []; - if ($lineItemValue = CRM_Utils_Array::value($participantNum, $lineItems)) { + if ($lineItemValue = ($lineItems[$participantNum] ?? NULL)) { $lineItem[] = $lineItemValue; } if (CRM_Invoicing_Utils::isInvoicingEnabled()) { @@ -917,7 +915,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { 'invoice_id' => $params['invoiceID'], 'currency' => $params['currencyID'], 'source' => !empty($params['participant_source']) ? $params['participant_source'] : $params['description'], - 'is_pay_later' => CRM_Utils_Array::value('is_pay_later', $params, 0), + 'is_pay_later' => $params['is_pay_later'] ?? 0, 'campaign_id' => $params['campaign_id'] ?? NULL, 'card_type_id' => $params['card_type_id'] ?? NULL, 'pan_truncation' => $params['pan_truncation'] ?? NULL, @@ -942,7 +940,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { } $contribParams['is_test'] = 0; - if ($form->_action & CRM_Core_Action::PREVIEW || CRM_Utils_Array::value('mode', $params) == 'test') { + if ($form->_action & CRM_Core_Action::PREVIEW || ($params['mode'] ?? NULL) === 'test') { $contribParams['is_test'] = 1; } @@ -955,13 +953,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { } if (Civi::settings()->get('deferred_revenue_enabled')) { - $eventStartDate = CRM_Utils_Array::value( - 'start_date', - CRM_Utils_Array::value( - 'event', - $form->_values - ) - ); + $eventStartDate = $form->_values['event']['start_date'] ?? NULL; if (strtotime($eventStartDate) > strtotime(date('Ymt'))) { $contribParams['revenue_recognition_date'] = date('Ymd', strtotime($eventStartDate)); } @@ -1027,7 +1019,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { // Add the billing names to the billing address, if a billing name is set if (!empty($params['billing_first_name'])) { - $params["address_name-{$form->_bltID}"] = $params['billing_first_name'] . ' ' . CRM_Utils_Array::value('billing_middle_name', $params) . ' ' . CRM_Utils_Array::value('billing_last_name', $params); + $params["address_name-{$form->_bltID}"] = $params['billing_first_name'] . ' ' . ($params['billing_middle_name'] ?? '') . ' ' . ($params['billing_last_name'] ?? ''); $fields["address_name-{$form->_bltID}"] = 1; } @@ -1147,7 +1139,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { } //get email primary first if exist - $subscriptionEmail = ['email' => CRM_Utils_Array::value('email-Primary', $params)]; + $subscriptionEmail = ['email' => $params['email-Primary'] ?? NULL]; if (!$subscriptionEmail['email']) { $subscriptionEmail['email'] = $params["email-{$form->_bltID}"] ?? NULL; } -- 2.25.1