Skip to content

Commit

Permalink
Merge pull request #21063 from eileenmcnaughton/vars2
Browse files Browse the repository at this point in the history
[Ref] Clarify what parameters are passed in
  • Loading branch information
colemanw authored Aug 9, 2021
2 parents 6a9d9d7 + cd34577 commit b2b2235
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -2079,26 +2079,22 @@ public static function checkOnlinePendingContribution($componentId, $componentNa
*
*/
public static function transitionComponents($params) {
$contributionStatus = CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $params['contribution_status_id']);
$previousStatus = CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $params['previous_contribution_status_id']);
// @todo fix the one place that calls this function to use Payment.create
// remove this.
// get minimum required values.
$contactId = $params['contact_id'] ?? NULL;
$componentId = $params['component_id'] ?? NULL;
$componentName = $params['componentName'] ?? NULL;
$contributionId = $params['contribution_id'] ?? NULL;
$contributionStatusId = $params['contribution_status_id'] ?? NULL;
$contactId = NULL;
$componentId = NULL;
$componentName = NULL;
$contributionId = $params['contribution_id'];
$contributionStatusId = $params['contribution_status_id'];

// if we already processed contribution object pass previous status id.
$previousContriStatusId = $params['previous_contribution_status_id'] ?? NULL;

$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$previousContriStatusId = $params['previous_contribution_status_id'];

// we process only ( Completed, Cancelled, or Failed ) contributions.
if (!$contributionId ||
!in_array($contributionStatusId, [
array_search('Completed', $contributionStatuses),
])
) {
if (!$contributionId || $contributionStatus !== 'Completed') {
return;
}

Expand Down Expand Up @@ -2170,11 +2166,11 @@ public static function transitionComponents($params) {
'status_id'
);
}
if ($contributionStatusId == array_search('Completed', $contributionStatuses)) {
if ($contributionStatus === 'Completed') {

// only pending contribution related object processed.
if ($previousContriStatusId &&
!in_array($contributionStatuses[$previousContriStatusId], [
!in_array($previousStatus, [
'Pending',
'Partially paid',
])
Expand All @@ -2183,7 +2179,7 @@ public static function transitionComponents($params) {
return;
}
elseif (!$previousContriStatusId &&
!in_array($contributionStatuses[$contribution->contribution_status_id], [
!in_array($contributionStatus, [
'Pending',
'Partially paid',
])
Expand Down

0 comments on commit b2b2235

Please sign in to comment.