From a281a8ea22dbedadad7b5d8f1ca40dc0bd410dc5 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 21 Dec 2021 10:52:03 +1300 Subject: [PATCH] [REF] Remove now non-variable variables from previously shared code --- CRM/Contribute/Form/Contribution.php | 2 +- CRM/Contribute/Form/Contribution/Confirm.php | 35 +++++--------------- 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index da00945e8d9d..fc6e5fd5ea24 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -1285,7 +1285,7 @@ protected function processFormContribution( $result, $receiptDate, $recurringContributionID), $contributionParams ); - $contributionParams['non_deductible_amount'] = CRM_Contribute_Form_Contribution_Confirm::getNonDeductibleAmount($params, $financialType, $online, $form); + $contributionParams['non_deductible_amount'] = CRM_Contribute_Form_Contribution_Confirm::getNonDeductibleAmount($params, $financialType, FALSE, $form); $contributionParams['skipCleanMoney'] = TRUE; // @todo this is the wrong place for this - it should be done as close to form submission // as possible diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 7d7895e666e3..5c370325aa77 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -1013,10 +1013,6 @@ protected function postProcessPremium($premiumParams, $contribution) { /** * Process the contribution. * - * @todo - this code was previously shared with the backoffice form - some parts of this - * function may relate to that form, not this one. - * - * @param CRM_Core_Form $form * @param array $params * @param array $result * @param array $contributionParams @@ -1033,9 +1029,6 @@ protected function postProcessPremium($premiumParams, $contribution) { * - thankyou_date (not all forms will set this) * * @param CRM_Financial_DAO_FinancialType $financialType - * @param bool $online - * Is the form a front end form? If so set a bunch of unpredictable things that should be passed in from the form. - * * @param int $billingLocationID * ID of billing location type. * @param bool $isRecur @@ -1045,17 +1038,19 @@ protected function postProcessPremium($premiumParams, $contribution) { * * @throws \CRM_Core_Exception * @throws \CiviCRM_API3_Exception + * @todo - this code was previously shared with the backoffice form - some parts of this + * function may relate to that form, not this one. + * */ - protected static function processFormContribution( - &$form, + protected function processFormContribution( $params, $result, $contributionParams, $financialType, - $online, $billingLocationID, $isRecur ) { + $form = $this; $transaction = new CRM_Core_Transaction(); $contactID = $contributionParams['contact_id']; @@ -1100,7 +1095,7 @@ protected static function processFormContribution( $result, $receiptDate, $recurringContributionID), $contributionParams ); - $contributionParams['non_deductible_amount'] = self::getNonDeductibleAmount($params, $financialType, $online, $form); + $contributionParams['non_deductible_amount'] = self::getNonDeductibleAmount($params, $financialType, TRUE, $form); $contributionParams['skipCleanMoney'] = TRUE; // @todo this is the wrong place for this - it should be done as close to form submission // as possible @@ -1143,22 +1138,13 @@ protected static function processFormContribution( $form = self::handlePledge($form, $params, $contributionParams, $pledgeID, $contribution, $isEmailReceipt); } - if ($online && $contribution) { + if ($contribution) { CRM_Core_BAO_CustomValueTable::postProcess($params, 'civicrm_contribution', $contribution->id, 'Contribution' ); } - elseif ($contribution) { - //handle custom data. - $params['contribution_id'] = $contribution->id; - if (!empty($params['custom']) && - is_array($params['custom']) - ) { - CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_contribution', $contribution->id); - } - } // Save note if ($contribution && !empty($params['contribution_note'])) { $noteParams = [ @@ -1845,12 +1831,11 @@ protected function processSecondaryFinancialTransaction($contactID, &$form, $tem // CRM-19792 : set necessary fields for payment processor CRM_Core_Payment_Form::mapParams($form->_bltID, $form->_params, $tempParams, TRUE); - $membershipContribution = CRM_Contribute_Form_Contribution_Confirm::processFormContribution($form, + $membershipContribution = $this->processFormContribution( $tempParams, $tempParams, $contributionParams, $financialType, - TRUE, $form->_bltID, $isRecur ); @@ -2711,13 +2696,11 @@ public function processConfirm( if (!empty($form->_paymentProcessor)) { $contributionParams['payment_instrument_id'] = $paymentParams['payment_instrument_id'] = $form->_paymentProcessor['payment_instrument_id']; } - $contribution = CRM_Contribute_Form_Contribution_Confirm::processFormContribution( - $form, + $contribution = $this->processFormContribution( $paymentParams, NULL, $contributionParams, $financialType, - TRUE, $form->_bltID, $isRecur );