Skip to content

Commit

Permalink
[NFC] Code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Jan 18, 2020
1 parent 3ecd083 commit 59ffd0e
Showing 1 changed file with 39 additions and 38 deletions.
77 changes: 39 additions & 38 deletions CRM/Contribute/BAO/ContributionSoft.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static function processSoftContribution($params, $contribution) {
$pcpId = self::getSoftCreditIds($contribution->id, TRUE);

if ($pcp = CRM_Utils_Array::value('pcp', $params)) {
$softParams = array();
$softParams = [];
$softParams['id'] = $pcpId ? $pcpId : NULL;
$softParams['contribution_id'] = $contribution->id;
$softParams['pcp_id'] = $pcp['pcp_made_through_id'];
Expand All @@ -83,7 +83,7 @@ public static function processSoftContribution($params, $contribution) {
}
//Delete PCP against this contribution and create new on submitted PCP information
elseif (array_key_exists('pcp', $params) && $pcpId) {
civicrm_api3('ContributionSoft', 'delete', array('id' => $pcpId));
civicrm_api3('ContributionSoft', 'delete', ['id' => $pcpId]);
}
if (isset($params['soft_credit'])) {
$softParams = $params['soft_credit'];
Expand All @@ -105,7 +105,7 @@ public static function processSoftContribution($params, $contribution) {
// delete any extra soft-credit while updating back-office contribution
foreach ((array) $softIDs as $softID) {
if (!in_array($softID, $params['soft_credit_ids'])) {
civicrm_api3('ContributionSoft', 'delete', array('id' => $softID));
civicrm_api3('ContributionSoft', 'delete', ['id' => $softID]);
}
}
}
Expand All @@ -121,14 +121,14 @@ public static function processSoftContribution($params, $contribution) {
* Form object.
*/
public static function formatSoftCreditParams(&$params, &$form) {
$pcp = $softParams = $softIDs = array();
$pcp = $softParams = $softIDs = [];
if (!empty($params['pcp_made_through_id'])) {
$fields = array(
$fields = [
'pcp_made_through_id',
'pcp_display_in_roll',
'pcp_roll_nickname',
'pcp_personal_note',
);
];
foreach ($fields as $f) {
$pcp[$f] = CRM_Utils_Array::value($f, $params);
}
Expand All @@ -141,10 +141,10 @@ public static function formatSoftCreditParams(&$params, &$form) {
$contributionSoftParams['soft_credit_type_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_ContributionSoft', 'soft_credit_type_id', 'pcp');
//check if there is any duplicate contact
// honoree should never be the donor
$exceptKeys = array(
$exceptKeys = [
'contactID' => 0,
'onbehalf_contact_id' => 0,
);
];
$except = array_values(array_intersect_key($params, $exceptKeys));
$ids = CRM_Contact_BAO_Contact::getDuplicateContacts(
$params['honor'],
Expand All @@ -163,21 +163,21 @@ public static function formatSoftCreditParams(&$params, &$form) {
$honorId, NULL,
$form->_values['honoree_profile_id']
);
$softParams[] = array(
$softParams[] = [
'contact_id' => $honorId,
'soft_credit_type_id' => $params['soft_credit_type_id'],
);
];

if (CRM_Utils_Array::value('is_email_receipt', $form->_values)) {
$form->_values['honor'] = array(
$form->_values['honor'] = [
'soft_credit_type' => CRM_Utils_Array::value(
$params['soft_credit_type_id'],
CRM_Core_OptionGroup::values("soft_credit_type")
),
'honor_id' => $honorId,
'honor_profile_id' => $form->_values['honoree_profile_id'],
'honor_profile_values' => $params['honor'],
);
];
}
}
elseif (!empty($params['soft_credit_contact_id'])) {
Expand Down Expand Up @@ -236,15 +236,15 @@ public static function getSoftContributionTotals($contact_id, $isTest = 0) {
WHERE cc.is_test = %2 AND ccs.contact_id = %1 {$whereClause}
GROUP BY currency";

$params = array(
1 => array($contact_id, 'Integer'),
2 => array($isTest, 'Integer'),
);
$params = [
1 => [$contact_id, 'Integer'],
2 => [$isTest, 'Integer'],
];

$cs = CRM_Core_DAO::executeQuery($query, $params);

$count = $countCancelled = 0;
$amount = $average = $cancelAmount = array();
$amount = $average = $cancelAmount = [];

while ($cs->fetch()) {
if ($cs->amount > 0) {
Expand All @@ -257,7 +257,7 @@ public static function getSoftContributionTotals($contact_id, $isTest = 0) {
//to get cancel amount
$cancelAmountWhereClause = "AND cc.cancel_date IS NOT NULL";
$query = str_replace($whereClause, $cancelAmountWhereClause, $query);
$cancelAmountSQL = CRM_Core_DAO::executeQuery($query, $params);
$cancelAmountSQL = CRM_Core_DAO::executeQuery($query, $params);
while ($cancelAmountSQL->fetch()) {
if ($cancelAmountSQL->amount > 0) {
$countCancelled++;
Expand All @@ -266,15 +266,15 @@ public static function getSoftContributionTotals($contact_id, $isTest = 0) {
}

if ($count > 0 || $countCancelled > 0) {
return array(
return [
$count,
$countCancelled,
implode(', ', $amount),
implode(', ', $average),
implode(', ', $cancelAmount),
);
];
}
return array(0, 0);
return [0, 0];
}

/**
Expand Down Expand Up @@ -368,10 +368,10 @@ public static function getSoftCreditIds($contributionID, $isPCP = FALSE) {
else {
$query .= " AND pcp_id IS NULL";
}
$params = array(1 => array($contributionID, 'Integer'));
$params = [1 => [$contributionID, 'Integer']];

$dao = CRM_Core_DAO::executeQuery($query, $params);
$id = array();
$id = [];
$type = '';
while ($dao->fetch()) {
if ($isPCP) {
Expand Down Expand Up @@ -409,7 +409,7 @@ public static function getSoftContributionSelector($params) {

$softCreditList = self::getSoftContributionList($contactId, $filter, $isTest, $params);

$softCreditListDT = array();
$softCreditListDT = [];
$softCreditListDT['data'] = array_values($softCreditList);
$softCreditListDT['recordsTotal'] = $params['total'];
$softCreditListDT['recordsFiltered'] = $params['total'];
Expand All @@ -431,14 +431,14 @@ public static function getSoftContributionSelector($params) {
*/
public static function getSoftContributionList($contact_id, $filter = NULL, $isTest = 0, &$dTParams = NULL) {
$config = CRM_Core_Config::singleton();
$links = array(
CRM_Core_Action::VIEW => array(
$links = [
CRM_Core_Action::VIEW => [
'name' => ts('View'),
'url' => 'civicrm/contact/view/contribution',
'qs' => 'reset=1&id=%%contributionid%%&cid=%%contactId%%&action=view&context=contribution&selectedChild=contribute',
'title' => ts('View related contribution'),
),
);
],
];
$orderBy = 'cc.receive_date DESC';
if (!empty($dTParams['sort'])) {
$orderBy = $dTParams['sort'];
Expand Down Expand Up @@ -487,16 +487,16 @@ public static function getSoftContributionList($contact_id, $filter = NULL, $isT

$query .= "{$where} ORDER BY {$orderBy} {$limit}";

$params = array(
1 => array($contact_id, 'Integer'),
2 => array($isTest, 'Integer'),
3 => array($softOgId, 'Integer'),
4 => array($statusOgId, 'Integer'),
);
$params = [
1 => [$contact_id, 'Integer'],
2 => [$isTest, 'Integer'],
3 => [$softOgId, 'Integer'],
4 => [$statusOgId, 'Integer'],
];
$cs = CRM_Core_DAO::executeQuery($query, $params);

$dTParams['total'] = CRM_Core_DAO::singleValueQuery('SELECT FOUND_ROWS()');
$result = array();
$result = [];
while ($cs->fetch()) {
$result[$cs->id]['amount'] = CRM_Utils_Money::format($cs->amount, $cs->currency);
$result[$cs->id]['currency'] = $cs->currency;
Expand All @@ -516,10 +516,10 @@ public static function getSoftContributionList($contact_id, $filter = NULL, $isT
$result[$cs->id]['pcp_personal_note'] = $cs->pcp_personal_note;
$result[$cs->id]['contribution_status'] = $cs->contribution_status;
$result[$cs->id]['sct_label'] = $cs->sct_label;
$replace = array(
$replace = [
'contributionid' => $cs->contribution_id,
'contactId' => $cs->contributor_id,
);
];
$result[$cs->id]['links'] = CRM_Core_Action::formLink($links, NULL, $replace);

if ($isTest) {
Expand All @@ -544,7 +544,7 @@ public static function formatHonoreeProfileFields($form, $params, $honorId = NUL
}
$profileContactType = CRM_Core_BAO_UFGroup::getContactType($form->_values['honoree_profile_id']);
$profileFields = CRM_Core_BAO_UFGroup::getFields($form->_values['honoree_profile_id']);
$honoreeProfileFields = $values = array();
$honoreeProfileFields = $values = [];
$honorName = NULL;

if ($honorId) {
Expand Down Expand Up @@ -603,3 +603,4 @@ public static function formatHonoreeProfileFields($form, $params, $honorId = NUL
}

}

0 comments on commit 59ffd0e

Please sign in to comment.