From 4a413eb6af015cfec3425b6fe3ddb3292562cbe4 Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Mon, 1 Jul 2019 17:53:29 -0400 Subject: [PATCH] Use correct caps for CRM_Core_PseudoConstant everywhere --- CRM/Batch/Form/Entry.php | 6 +++--- CRM/Core/BAO/CustomField.php | 4 ++-- CRM/Core/BAO/FinancialTrxn.php | 2 +- CRM/Core/OptionGroup.php | 2 +- CRM/Core/Payment/PayPalIPN.php | 4 ++-- CRM/Core/Payment/PayPalProIPN.php | 6 +++--- CRM/Report/Form/Contact/Relationship.php | 4 ++-- api/v3/Activity.php | 7 ++++--- api/v3/Campaign.php | 4 ++-- api/v3/Event.php | 2 +- tests/phpunit/CRM/Contribute/Form/SearchTest.php | 2 +- tests/phpunit/CRM/Member/Form/MembershipTest.php | 2 +- 12 files changed, 23 insertions(+), 22 deletions(-) diff --git a/CRM/Batch/Form/Entry.php b/CRM/Batch/Form/Entry.php index 4d0671fa8e..b787b344a5 100644 --- a/CRM/Batch/Form/Entry.php +++ b/CRM/Batch/Form/Entry.php @@ -143,7 +143,7 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form { $this->addElement('hidden', 'batch_id', $this->_batchId); - $batchTypes = CRM_Core_Pseudoconstant::get('CRM_Batch_DAO_Batch', 'type_id', ['flip' => 1], 'validate'); + $batchTypes = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'type_id', ['flip' => 1], 'validate'); // get the profile information if ($this->_batchInfo['type_id'] == $batchTypes['Contribution']) { CRM_Utils_System::setTitle(ts('Batch Data Entry for Contributions')); @@ -298,7 +298,7 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form { */ public static function formRule($params, $files, $self) { $errors = []; - $batchTypes = CRM_Core_Pseudoconstant::get('CRM_Batch_DAO_Batch', 'type_id', ['flip' => 1], 'validate'); + $batchTypes = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'type_id', ['flip' => 1], 'validate'); $fields = [ 'total_amount' => ts('Amount'), 'financial_type' => ts('Financial Type'), @@ -564,7 +564,7 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form { $value['skipCleanMoney'] = TRUE; //finally call contribution create for all the magic $contribution = CRM_Contribute_BAO_Contribution::create($value); - $batchTypes = CRM_Core_Pseudoconstant::get('CRM_Batch_DAO_Batch', 'type_id', ['flip' => 1], 'validate'); + $batchTypes = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'type_id', ['flip' => 1], 'validate'); if (!empty($this->_batchInfo['type_id']) && ($this->_batchInfo['type_id'] == $batchTypes['Pledge Payment'])) { $adjustTotalAmount = FALSE; if (isset($params['option_type'][$key])) { diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index 8d22e52f21..c0fb792829 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -416,10 +416,10 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { ); } elseif ($this->data_type === 'StateProvince') { - $options = CRM_Core_Pseudoconstant::stateProvince(); + $options = CRM_Core_PseudoConstant::stateProvince(); } elseif ($this->data_type === 'Country') { - $options = $context == 'validate' ? CRM_Core_Pseudoconstant::countryIsoCode() : CRM_Core_Pseudoconstant::country(); + $options = $context == 'validate' ? CRM_Core_PseudoConstant::countryIsoCode() : CRM_Core_PseudoConstant::country(); } elseif ($this->data_type === 'Boolean') { $options = $context == 'validate' ? array(0, 1) : CRM_Core_SelectValues::boolean(); diff --git a/CRM/Core/BAO/FinancialTrxn.php b/CRM/Core/BAO/FinancialTrxn.php index 6b3d453369..742ad4aeb2 100644 --- a/CRM/Core/BAO/FinancialTrxn.php +++ b/CRM/Core/BAO/FinancialTrxn.php @@ -429,7 +429,7 @@ WHERE ceft.entity_id = %1"; 'transaction_date' => date('YmdHis'), 'amount' => $amount, 'description' => 'Fee', - 'status_id' => CRM_Core_Pseudoconstant::getKey('CRM_Financial_BAO_FinancialItem', 'status_id', 'Paid'), + 'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Financial_BAO_FinancialItem', 'status_id', 'Paid'), 'entity_table' => 'civicrm_financial_trxn', 'entity_id' => $params['entity_id'], 'currency' => $params['trxnParams']['currency'], diff --git a/CRM/Core/OptionGroup.php b/CRM/Core/OptionGroup.php index 913f874d50..1bf006722d 100644 --- a/CRM/Core/OptionGroup.php +++ b/CRM/Core/OptionGroup.php @@ -334,7 +334,7 @@ WHERE v.option_group_id = g.id } /** - * @deprecated - use CRM_Core_Pseudoconstant::getLabel + * @deprecated - use CRM_Core_PseudoConstant::getLabel * * @param string $groupName * @param $value diff --git a/CRM/Core/Payment/PayPalIPN.php b/CRM/Core/Payment/PayPalIPN.php index cb68eff201..5e0a1034be 100644 --- a/CRM/Core/Payment/PayPalIPN.php +++ b/CRM/Core/Payment/PayPalIPN.php @@ -290,7 +290,7 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { } // check if contribution is already completed, if so we ignore this ipn - $completedStatusId = CRM_Core_Pseudoconstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'); + $completedStatusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'); if ($contribution->contribution_status_id == $completedStatusId) { $transaction->commit(); Civi::log()->debug('PayPalIPN: Returning since contribution has already been handled. (ID: ' . $contribution->id . ').'); @@ -343,7 +343,7 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { if ($ids['contributionRecur']) { // check if first contribution is completed, else complete first contribution $first = TRUE; - $completedStatusId = CRM_Core_Pseudoconstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'); + $completedStatusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'); if ($objects['contribution']->contribution_status_id == $completedStatusId) { $first = FALSE; } diff --git a/CRM/Core/Payment/PayPalProIPN.php b/CRM/Core/Payment/PayPalProIPN.php index be4da0c8fc..0324019d9f 100644 --- a/CRM/Core/Payment/PayPalProIPN.php +++ b/CRM/Core/Payment/PayPalProIPN.php @@ -381,7 +381,7 @@ class CRM_Core_Payment_PayPalProIPN extends CRM_Core_Payment_BaseIPN { } // check if contribution is already completed, if so we ignore this ipn - $completedStatusId = CRM_Core_Pseudoconstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'); + $completedStatusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'); if ($contribution->contribution_status_id == $completedStatusId) { $transaction->commit(); Civi::log()->debug('PayPalProIPN: Returning since contribution has already been handled.'); @@ -487,7 +487,7 @@ INNER JOIN civicrm_membership_payment mp ON m.id = mp.membership_id AND mp.contr if ($ids['contributionRecur']) { // check if first contribution is completed, else complete first contribution $first = TRUE; - $completedStatusId = CRM_Core_Pseudoconstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'); + $completedStatusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'); if ($objects['contribution']->contribution_status_id == $completedStatusId) { $first = FALSE; } @@ -586,7 +586,7 @@ INNER JOIN civicrm_membership_payment mp ON m.id = mp.membership_id AND mp.contr $ids['contribution'] = $result['id']; //@todo hardcoding 'pending' for now - $pendingStatusId = CRM_Core_Pseudoconstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending'); + $pendingStatusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending'); if ($result['contribution_status_id'] == $pendingStatusId) { $isFirst = TRUE; } diff --git a/CRM/Report/Form/Contact/Relationship.php b/CRM/Report/Form/Contact/Relationship.php index c29ec8e505..bb0816c8db 100644 --- a/CRM/Report/Form/Contact/Relationship.php +++ b/CRM/Report/Form/Contact/Relationship.php @@ -696,7 +696,7 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { $rowLabels = []; foreach ($rowValues as $rowValue) { if ($rowValue) { - $rowLabels[] = CRM_Core_Pseudoconstant::getLabel('CRM_Contact_BAO_Contact', 'contact_sub_type', $rowValue); + $rowLabels[] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_BAO_Contact', 'contact_sub_type', $rowValue); } } $rows[$rowNum]['civicrm_contact_contact_sub_type_a'] = implode(', ', $rowLabels); @@ -712,7 +712,7 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { $rowLabels = []; foreach ($rowValues as $rowValue) { if ($rowValue) { - $rowLabels[] = CRM_Core_Pseudoconstant::getLabel('CRM_Contact_BAO_Contact', 'contact_sub_type', $rowValue); + $rowLabels[] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_BAO_Contact', 'contact_sub_type', $rowValue); } } $rows[$rowNum]['civicrm_contact_b_contact_sub_type_b'] = implode(', ', $rowLabels); diff --git a/api/v3/Activity.php b/api/v3/Activity.php index 4aa31a9da1..784095e0e4 100644 --- a/api/v3/Activity.php +++ b/api/v3/Activity.php @@ -354,10 +354,11 @@ function civicrm_api3_activity_get($params) { */ function _civicrm_activity_get_handleSourceContactNameOrderBy(&$params, &$options, $sql) { $sourceContactID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_ActivityContact', 'record_type_id', 'Activity Source'); - if (!empty($options['sort']) && in_array($options['sort'], [ + if (!empty($options['sort']) + && in_array($options['sort'], [ 'source_contact_name', 'source_contact_name desc', - 'source_contact_name asc' + 'source_contact_name asc', ])) { $order = substr($options['sort'], -4) === 'desc' ? 'desc' : 'asc'; $sql->join( @@ -805,7 +806,7 @@ function _civicrm_api3_activity_getlist_output($result, $request) { 'id' => $row[$request['id_field']], 'label' => $row[$request['label_field']] ? $row[$request['label_field']] : ts('(no subject)'), 'description' => [ - CRM_Core_Pseudoconstant::getLabel('CRM_Activity_BAO_Activity', 'activity_type_id', $row['activity_type_id']), + CRM_Core_PseudoConstant::getLabel('CRM_Activity_BAO_Activity', 'activity_type_id', $row['activity_type_id']), ], ]; if (!empty($row['activity_date_time'])) { diff --git a/api/v3/Campaign.php b/api/v3/Campaign.php index 29c6be4720..383d556f04 100644 --- a/api/v3/Campaign.php +++ b/api/v3/Campaign.php @@ -126,11 +126,11 @@ function _civicrm_api3_campaign_getlist_output($result, $request) { 'id' => $row[$request['id_field']], 'label' => $row[$request['label_field']], 'description' => [ - CRM_Core_Pseudoconstant::getLabel('CRM_Campaign_BAO_Campaign', 'campaign_type_id', $row['campaign_type_id']), + CRM_Core_PseudoConstant::getLabel('CRM_Campaign_BAO_Campaign', 'campaign_type_id', $row['campaign_type_id']), ], ]; if (!empty($row['status_id'])) { - $data['description'][0] .= ': ' . CRM_Core_Pseudoconstant::getLabel('CRM_Campaign_BAO_Campaign', 'status_id', $row['status_id']); + $data['description'][0] .= ': ' . CRM_Core_PseudoConstant::getLabel('CRM_Campaign_BAO_Campaign', 'status_id', $row['status_id']); } $dateString = CRM_Utils_Date::customFormat($row['start_date'], $config->dateformatFull) . ' -'; if (!empty($row['end_date'])) { diff --git a/api/v3/Event.php b/api/v3/Event.php index 5f58ebc675..b3dbd7adcd 100644 --- a/api/v3/Event.php +++ b/api/v3/Event.php @@ -254,7 +254,7 @@ function _civicrm_api3_event_getlist_output($result, $request) { 'id' => $row[$request['id_field']], 'label' => $row[$request['label_field']], 'description' => [ - CRM_Core_Pseudoconstant::getLabel('CRM_Event_BAO_Event', 'event_type_id', $row['event_type_id']), + CRM_Core_PseudoConstant::getLabel('CRM_Event_BAO_Event', 'event_type_id', $row['event_type_id']), ], ]; if (!empty($row['start_date'])) { diff --git a/tests/phpunit/CRM/Contribute/Form/SearchTest.php b/tests/phpunit/CRM/Contribute/Form/SearchTest.php index f773d1dd5b..fab3b2d36a 100644 --- a/tests/phpunit/CRM/Contribute/Form/SearchTest.php +++ b/tests/phpunit/CRM/Contribute/Form/SearchTest.php @@ -64,7 +64,7 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { $batch = $this->callAPISuccess('Batch', 'create', [ 'created_id' => $this->_individual, 'created_date' => CRM_Utils_Date::processDate(date("Y-m-d"), date("H:i:s")), - 'status_id' => CRM_Core_Pseudoconstant::getKey('CRM_Batch_BAO_Batch', 'status_id', 'Data Entry'), + 'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Batch_BAO_Batch', 'status_id', 'Data Entry'), 'title' => $batchTitle, 'item_count' => 2, 'total' => 100, diff --git a/tests/phpunit/CRM/Member/Form/MembershipTest.php b/tests/phpunit/CRM/Member/Form/MembershipTest.php index d9db47e38c..f00b4fa1be 100644 --- a/tests/phpunit/CRM/Member/Form/MembershipTest.php +++ b/tests/phpunit/CRM/Member/Form/MembershipTest.php @@ -1339,7 +1339,7 @@ Expires: ', 'contact_id' => $this->_individualId, 'id' => $lineItem['contribution_id'], 'financial_type_id' => 2, - 'contribution_status_id' => CRM_Core_Pseudoconstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'), + 'contribution_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'), ), CRM_Core_Action::UPDATE); -- 2.25.1