Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Convert previously shared function to non-static, remove unrelated code #19258

Merged
merged 1 commit into from
Dec 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So just to articulate here, the reason for this is because no Contribution Custom fields are exposed on the Back office Membership form right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seamuslee001 exactly

//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