From efb1764c4afe2cac1dcaf3e4469fcab18033ae9c Mon Sep 17 00:00:00 2001 From: eileen Date: Sat, 18 Jan 2020 20:04:52 +1300 Subject: [PATCH] [NFC] Code formatting --- CRM/Contribute/BAO/ContributionSoft.php | 76 ++++++++++++------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/CRM/Contribute/BAO/ContributionSoft.php b/CRM/Contribute/BAO/ContributionSoft.php index c98c5ccd11..3923e5f73b 100644 --- a/CRM/Contribute/BAO/ContributionSoft.php +++ b/CRM/Contribute/BAO/ContributionSoft.php @@ -62,7 +62,7 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio $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']; @@ -83,7 +83,7 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio } //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']; @@ -105,7 +105,7 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio // 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]); } } } @@ -121,14 +121,14 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio * 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); } @@ -141,10 +141,10 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio $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'], @@ -163,13 +163,13 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio $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") @@ -177,7 +177,7 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio 'honor_id' => $honorId, 'honor_profile_id' => $form->_values['honoree_profile_id'], 'honor_profile_values' => $params['honor'], - ); + ]; } } elseif (!empty($params['soft_credit_contact_id'])) { @@ -236,15 +236,15 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio 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) { @@ -257,7 +257,7 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio //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++; @@ -266,15 +266,15 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio } if ($count > 0 || $countCancelled > 0) { - return array( + return [ $count, $countCancelled, implode(', ', $amount), implode(', ', $average), implode(', ', $cancelAmount), - ); + ]; } - return array(0, 0); + return [0, 0]; } /** @@ -368,10 +368,10 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio 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) { @@ -409,7 +409,7 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio $softCreditList = self::getSoftContributionList($contactId, $filter, $isTest, $params); - $softCreditListDT = array(); + $softCreditListDT = []; $softCreditListDT['data'] = array_values($softCreditList); $softCreditListDT['recordsTotal'] = $params['total']; $softCreditListDT['recordsFiltered'] = $params['total']; @@ -431,14 +431,14 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio */ 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']; @@ -487,16 +487,16 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio $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; @@ -516,10 +516,10 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio $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) { @@ -544,7 +544,7 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio } $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) { -- 2.25.1