[REF] Remove now non-variable variables from previously shared code
authorEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 20 Dec 2021 21:52:03 +0000 (10:52 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 20 Dec 2021 21:52:57 +0000 (10:52 +1300)
CRM/Contribute/Form/Contribution.php
CRM/Contribute/Form/Contribution/Confirm.php

index da00945e8d9da26686a296426ff4b66f3efaf5eb..fc6e5fd5ea241f103aac2c9b50e9dc49a5c6d627 100644 (file)
@@ -1285,7 +1285,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
         $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
index 7d7895e666e3042f1b760e21cd62c8d5fd892d2e..5c370325aa776ebd752854a34c3d8d68ca56af9f 100644 (file)
@@ -1013,10 +1013,6 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
   /**
    * 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
    *   - 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
    *
    * @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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
         $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
     // 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       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
       );