Skip to content

Commit

Permalink
Merge pull request #18391 from demeritcowboy/utils-array-18207-1
Browse files Browse the repository at this point in the history
[REF] Swap out CRM_Utils_Array::value() - partial pull out from PR 18207
  • Loading branch information
seamuslee001 authored Sep 7, 2020
2 parents 4cc604b + d457833 commit b02a642
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public static function add(&$params) {
CRM_Contribute_BAO_ContributionRecur::updateOnNewPayment(
(!empty($params['contribution_recur_id']) ? $params['contribution_recur_id'] : $params['prevContribution']->contribution_recur_id),
$contributionStatus,
CRM_Utils_Array::value('receive_date', $params)
$params['receive_date'] ?? NULL
);
}

Expand Down Expand Up @@ -2262,7 +2262,7 @@ public static function transitionComponents($params, $processContributionObject
$numterms = 1;
$lineitems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($contributionId);
foreach ($lineitems as $lineitem) {
if ($membership->membership_type_id == CRM_Utils_Array::value('membership_type_id', $lineitem)) {
if ($membership->membership_type_id == ($lineitem['membership_type_id'] ?? NULL)) {
$numterms = $lineitem['membership_num_terms'] ?? NULL;

// in case membership_num_terms comes through as null or zero
Expand Down Expand Up @@ -2324,7 +2324,7 @@ public static function transitionComponents($params, $processContributionObject
//updating the membership log
$membershipLog = [];
$membershipLog = $formattedParams;
$logStartDate = CRM_Utils_Date::customFormat(CRM_Utils_Array::value('log_start_date', $dates), $format);
$logStartDate = CRM_Utils_Date::customFormat($dates['log_start_date'] ?? NULL, $format);
$logStartDate = ($logStartDate) ? CRM_Utils_Date::isoToMysql($logStartDate) : $formattedParams['start_date'];

$membershipLog['start_date'] = $logStartDate;
Expand Down Expand Up @@ -3237,7 +3237,7 @@ public function _assignMessageVariablesToTemplate(&$values, $input, $returnMessa

// For some unit tests contribution cannot contain paymentProcessor information
$billingMode = empty($this->_relatedObjects['paymentProcessor']) ? CRM_Core_Payment::BILLING_MODE_NOTIFY : $this->_relatedObjects['paymentProcessor']['billing_mode'];
$template->assign('contributeMode', CRM_Utils_Array::value($billingMode, CRM_Core_SelectValues::contributeMode()));
$template->assign('contributeMode', CRM_Core_SelectValues::contributeMode()[$billingMode] ?? NULL);

//assign honor information to receipt message
$softRecord = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($this->id);
Expand Down Expand Up @@ -3287,7 +3287,7 @@ public function _assignMessageVariablesToTemplate(&$values, $input, $returnMessa
$template->assign('price', $productDAO->price);
$template->assign('sku', $productDAO->sku);
}
$template->assign('title', CRM_Utils_Array::value('title', $values));
$template->assign('title', $values['title'] ?? NULL);
$values['amount'] = CRM_Utils_Array::value('total_amount', $input, (CRM_Utils_Array::value('amount', $input)), NULL);
if (!$values['amount'] && isset($this->total_amount)) {
$values['amount'] = $this->total_amount;
Expand Down Expand Up @@ -3333,11 +3333,7 @@ public function _assignMessageVariablesToTemplate(&$values, $input, $returnMessa
);
$values['receipt_date'] = (empty($this->receipt_date) ? NULL : $this->receipt_date);
$template->assign('action', $this->is_test ? 1024 : 1);
$template->assign('receipt_text',
CRM_Utils_Array::value('receipt_text',
$values
)
);
$template->assign('receipt_text', $values['receipt_text'] ?? NULL);
$template->assign('is_monetary', 1);
$template->assign('is_recur', !empty($this->contribution_recur_id));
$template->assign('currency', $this->currency);
Expand Down

0 comments on commit b02a642

Please sign in to comment.