Skip to content

Commit

Permalink
Merge pull request #19258 from eileenmcnaughton/recur_test
Browse files Browse the repository at this point in the history
[REF] Convert previously shared function to non-static, remove unrelated code
  • Loading branch information
colemanw authored Dec 23, 2020
2 parents f0eff43 + 2a32035 commit 179e6a1
Showing 1 changed file with 5 additions and 44 deletions.
49 changes: 5 additions & 44 deletions CRM/Member/Form/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ public static function emailReceipt(&$form, &$formValues, &$membership, $customV
// & we should aim to move this function to the BAO layer in future.
// however, we can assume that the contact_id passed in by the batch
// function will be the recipient
list($form->_contributorDisplayName, $form->_contributorEmail)
[$form->_contributorDisplayName, $form->_contributorEmail]
= CRM_Contact_BAO_Contact_Location::getEmailDetails($formValues['contact_id']);
if (empty($form->_receiptContactId) || $isBatchProcess) {
$form->_receiptContactId = $formValues['contact_id'];
Expand Down Expand Up @@ -1170,7 +1170,7 @@ public function submit() {
}

// Retrieve the name and email of the current user - this will be the FROM for the receipt email
list($userName) = CRM_Contact_BAO_Contact_Location::getEmailDetails(CRM_Core_Session::getLoggedInContactID());
[$userName] = CRM_Contact_BAO_Contact_Location::getEmailDetails(CRM_Core_Session::getLoggedInContactID());

//CRM-13981, allow different person as a soft-contributor of chosen type
if ($this->_contributorContactID != $this->_contactID) {
Expand Down Expand Up @@ -1295,7 +1295,7 @@ public function submit() {
$financialType->find(TRUE);
$this->_params = $formValues;

$contribution = self::processFormContribution($this,
$contribution = $this->processContribution(
$paymentParams,
NULL,
[
Expand Down Expand Up @@ -1839,7 +1839,6 @@ protected function getSelectedMembershipLabels(): string {
* It's like the contribution create being done here is actively bad and
* being fixed later.
*
* @param CRM_Core_Form $form
* @param array $params
* @param array $result
* @param array $contributionParams
Expand All @@ -1862,13 +1861,13 @@ protected function getSelectedMembershipLabels(): string {
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public static function processFormContribution(
&$form,
protected function processContribution(
$params,
$result,
$contributionParams,
$financialType
) {
$form = $this;
$transaction = new CRM_Core_Transaction();
$contactID = $contributionParams['contact_id'];

Expand Down Expand Up @@ -1920,44 +1919,6 @@ public static function processFormContribution(
//CRM-13981, processing honor contact into soft-credit contribution
CRM_Contribute_BAO_ContributionSoft::processSoftContribution($params, $contribution);

if ($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 = [
'entity_table' => 'civicrm_contribution',
'note' => $params['contribution_note'],
'entity_id' => $contribution->id,
'contact_id' => $contribution->contact_id,
];

CRM_Core_BAO_Note::add($noteParams, []);
}

//create contribution activity w/ individual and target
//activity w/ organisation contact id when onbelf, CRM-4027
$actParams = [];
$targetContactID = NULL;
if (!empty($params['onbehalf_contact_id'])) {
$actParams = [
'source_contact_id' => $params['onbehalf_contact_id'],
'on_behalf' => TRUE,
];
$targetContactID = $contribution->contact_id;
}

// create an activity record
if ($contribution) {
CRM_Activity_BAO_Activity::addActivity($contribution, 'Contribution', $targetContactID, $actParams);
}

$transaction->commit();
return $contribution;
}
Expand Down

0 comments on commit 179e6a1

Please sign in to comment.