From f92b42752f07b8e997f14728993c6380ae37fb60 Mon Sep 17 00:00:00 2001 From: colemanw <coleman@civicrm.org> Date: Sat, 31 Aug 2024 11:20:41 -0400 Subject: [PATCH] Pseudoconstant - Switch to buildOptions instead of calling CRM_Core_Pseudoconstant::get directly This has been the recommendation for a long time, and it makes code easier to refactor if everything does it the same way. --- CRM/ACL/Form/ACL.php | 4 ++-- CRM/ACL/Page/ACL.php | 4 ++-- CRM/Activity/BAO/Activity.php | 2 +- CRM/Activity/Form/Activity.php | 2 +- CRM/Admin/Form/MailSettings.php | 2 +- CRM/Admin/Form/Mapping.php | 2 +- CRM/Admin/Page/MailSettings.php | 2 +- CRM/Batch/BAO/Batch.php | 6 +++--- CRM/Contact/BAO/Contact/Utils.php | 4 ++-- CRM/Contact/BAO/Individual.php | 4 ++-- CRM/Contact/BAO/Query.php | 4 ++-- CRM/Contact/Form/Contact.php | 2 +- CRM/Contact/Form/Edit/OpenID.php | 2 +- CRM/Contact/Form/RelatedContact.php | 4 ++-- CRM/Contact/Form/Search/Builder.php | 6 +++--- CRM/Contact/Form/Search/Criteria.php | 8 ++++---- CRM/Contact/Form/Task/Label.php | 6 +++--- CRM/Contact/Form/Task/LabelCommon.php | 2 +- CRM/Contact/Import/Form/MapField.php | 8 ++++---- CRM/Contact/Page/Inline/CommunicationPreferences.php | 2 +- CRM/Contact/Page/Inline/Demographics.php | 2 +- CRM/Contact/Page/Inline/IM.php | 2 +- CRM/Contact/Page/Inline/Phone.php | 2 +- CRM/Contact/Page/Inline/Website.php | 2 +- CRM/Contact/Page/View/Summary.php | 2 +- CRM/Contact/Selector.php | 6 +++--- CRM/Contribute/BAO/ContributionSoft.php | 4 ++-- CRM/Core/BAO/Address.php | 2 +- CRM/Core/BAO/LocationType.php | 2 +- CRM/Core/BAO/Phone.php | 2 +- CRM/Core/BAO/UFGroup.php | 12 ++++++------ CRM/Core/Page/Basic.php | 2 +- CRM/Core/Permission.php | 2 +- CRM/Event/BAO/Event.php | 4 ++-- CRM/Event/Form/ManageEvent.php | 2 +- CRM/Event/Page/EventInfo.php | 2 +- CRM/Export/BAO/ExportProcessor.php | 6 +++--- CRM/Financial/BAO/EntityFinancialAccount.php | 4 ++-- CRM/Financial/BAO/FinancialItem.php | 2 +- CRM/Financial/Form/FinancialAccount.php | 2 +- CRM/Financial/Form/FinancialBatch.php | 2 +- CRM/Financial/Form/FinancialTypeAccount.php | 2 +- CRM/Financial/Page/FinancialAccount.php | 2 +- CRM/Financial/Page/FinancialTypeAccount.php | 4 ++-- CRM/Import/Parser.php | 6 +++--- CRM/Logging/Differ.php | 12 ++++++------ CRM/Mailing/Form/Approve.php | 2 +- CRM/Mailing/MailStore.php | 2 +- CRM/Member/Form/Membership.php | 4 ++-- CRM/Member/Form/Task/Label.php | 2 +- CRM/PCP/BAO/PCP.php | 2 +- CRM/Profile/Form.php | 2 +- CRM/Profile/Selector/Listings.php | 2 +- CRM/Report/Form.php | 4 ++-- CRM/Report/Form/Activity.php | 6 +++--- CRM/Report/Form/ActivitySummary.php | 4 ++-- CRM/Report/Form/Contribute/History.php | 2 +- CRM/Report/Form/Contribute/Lybunt.php | 2 +- CRM/Report/Form/Contribute/SoftCredit.php | 2 +- CRM/Report/Form/Contribute/Sybunt.php | 2 +- CRM/Report/Form/Event/ParticipantListCount.php | 2 +- CRM/SMS/Provider.php | 4 ++-- CRM/UF/Form/Field.php | 6 +++--- CRM/UF/Page/Field.php | 3 +-- CRM/UF/Page/Group.php | 2 +- CRM/UF/Page/ProfileEditor.php | 6 +++--- Civi/API/Subscriber/PermissionCheck.php | 2 +- api/v3/Contact.php | 2 +- ext/civigrant/CRM/Grant/BAO/Grant.php | 2 +- ext/civigrant/CRM/Grant/Form/GrantView.php | 4 ++-- ext/civigrant/CRM/Grant/Form/Task/Update.php | 2 +- ext/civigrant/CRM/Report/Form/Grant/Detail.php | 4 ++-- ext/civigrant/CRM/Report/Form/Grant/Statistics.php | 10 +++++----- tests/phpunit/CRM/Contact/BAO/ContactTest.php | 8 ++++---- 74 files changed, 131 insertions(+), 132 deletions(-) diff --git a/CRM/ACL/Form/ACL.php b/CRM/ACL/Form/ACL.php index 2a2293b1eee..5e3722bb690 100644 --- a/CRM/ACL/Form/ACL.php +++ b/CRM/ACL/Form/ACL.php @@ -141,12 +141,12 @@ class CRM_ACL_Form_ACL extends CRM_Admin_Form { $customGroup = [ '-1' => ts('- select set of custom fields -'), '0' => ts('All Custom Groups'), - ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id'); + ] + CRM_Core_DAO_CustomField::buildOptions('custom_group_id'); $ufGroup = [ '-1' => ts('- select profile -'), '0' => ts('All Profiles'), - ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); + ] + CRM_Core_DAO_UFField::buildOptions('uf_group_id'); $event = [ '-1' => ts('- select event -'), diff --git a/CRM/ACL/Page/ACL.php b/CRM/ACL/Page/ACL.php index 4f14e446163..d7760e85110 100644 --- a/CRM/ACL/Page/ACL.php +++ b/CRM/ACL/Page/ACL.php @@ -65,11 +65,11 @@ class CRM_ACL_Page_ACL extends CRM_Core_Page_Basic { $customGroup = [ '-1' => ts('- select -'), '0' => ts('All Custom Groups'), - ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id'); + ] + CRM_Core_DAO_CustomField::buildOptions('custom_group_id'); $ufGroup = [ '-1' => ts('- select -'), '0' => ts('All Profiles'), - ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); + ] + CRM_Core_DAO_UFField::buildOptions('uf_group_id'); $event = [ '-1' => ts('- select -'), diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index 84d50b11feb..b6231c4d7ce 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -290,7 +290,7 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity { // if not set and not 0 empty($params['id']) ) { - $priority = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'); + $priority = CRM_Activity_DAO_Activity::buildOptions('priority_id'); $params['priority_id'] = array_search('Normal', $priority); } diff --git a/CRM/Activity/Form/Activity.php b/CRM/Activity/Form/Activity.php index 54ca884e01c..9cf4f1fc177 100644 --- a/CRM/Activity/Form/Activity.php +++ b/CRM/Activity/Form/Activity.php @@ -575,7 +575,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { $defaults += $className::setDefaultValues($this); } if (empty($defaults['priority_id'])) { - $priority = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'); + $priority = CRM_Activity_DAO_Activity::buildOptions('priority_id'); $defaults['priority_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_DAO_Activity', 'priority_id', 'Normal'); } if (empty($defaults['status_id'])) { diff --git a/CRM/Admin/Form/MailSettings.php b/CRM/Admin/Form/MailSettings.php index 6866c431d97..e717cf1b8e9 100644 --- a/CRM/Admin/Form/MailSettings.php +++ b/CRM/Admin/Form/MailSettings.php @@ -66,7 +66,7 @@ class CRM_Admin_Form_MailSettings extends CRM_Admin_Form { $this->add('select', 'protocol', ts('Protocol'), - ['' => ts('- select -')] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_MailSettings', 'protocol'), + ['' => ts('- select -')] + CRM_Core_DAO_MailSettings::buildOptions('protocol'), TRUE ); diff --git a/CRM/Admin/Form/Mapping.php b/CRM/Admin/Form/Mapping.php index 941fb616b7b..ca65f134620 100644 --- a/CRM/Admin/Form/Mapping.php +++ b/CRM/Admin/Form/Mapping.php @@ -64,7 +64,7 @@ class CRM_Admin_Form_Mapping extends CRM_Admin_Form { CRM_Core_DAO::getAttribute('CRM_Core_DAO_Mapping', 'description') ); - $mappingType = $this->addElement('select', 'mapping_type_id', ts('Mapping Type'), CRM_Core_PseudoConstant::get('CRM_Core_DAO_Mapping', 'mapping_type_id')); + $mappingType = $this->addElement('select', 'mapping_type_id', ts('Mapping Type'), CRM_Core_DAO_Mapping::buildOptions('mapping_type_id')); if ($this->_action == CRM_Core_Action::UPDATE) { $mappingType->freeze(); diff --git a/CRM/Admin/Page/MailSettings.php b/CRM/Admin/Page/MailSettings.php index e4b27ab05e5..7df8eabc37e 100644 --- a/CRM/Admin/Page/MailSettings.php +++ b/CRM/Admin/Page/MailSettings.php @@ -39,7 +39,7 @@ class CRM_Admin_Page_MailSettings extends CRM_Core_Page_Basic { $allMailSettings = []; $mailSetting = new CRM_Core_DAO_MailSettings(); - $allProtocols = CRM_Core_PseudoConstant::get('CRM_Core_DAO_MailSettings', 'protocol'); + $allProtocols = CRM_Core_DAO_MailSettings::buildOptions('protocol'); //multi-domain support for mail settings. CRM-5244 $mailSetting->domain_id = CRM_Core_Config::domainID(); diff --git a/CRM/Batch/BAO/Batch.php b/CRM/Batch/BAO/Batch.php index 663072d4ef3..4f8f1067eac 100644 --- a/CRM/Batch/BAO/Batch.php +++ b/CRM/Batch/BAO/Batch.php @@ -252,8 +252,8 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch implements \Civi\Core\Hook $links = $obj->links(); } - $batchTypes = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'type_id'); - $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id'); + $batchTypes = CRM_Batch_DAO_Batch::buildOptions('type_id'); + $batchStatus = CRM_Batch_DAO_Batch::buildOptions('status_id'); $batchStatusByName = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id', ['labelColumn' => 'name']); $paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument(); @@ -626,7 +626,7 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch implements \Civi\Core\Hook * @param $status */ public static function closeReOpen($batchIds, $status) { - $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id'); + $batchStatus = CRM_Batch_DAO_Batch::buildOptions('status_id'); $params['status_id'] = CRM_Utils_Array::key($status, $batchStatus); $session = CRM_Core_Session::singleton(); $params['modified_date'] = date('YmdHis'); diff --git a/CRM/Contact/BAO/Contact/Utils.php b/CRM/Contact/BAO/Contact/Utils.php index 4cdca81199f..d845a192499 100644 --- a/CRM/Contact/BAO/Contact/Utils.php +++ b/CRM/Contact/BAO/Contact/Utils.php @@ -494,7 +494,7 @@ WHERE id={$contactId}; "; default: // individual $form->addElement('select', 'prefix_id', ts('Prefix'), - ['' => ts('- prefix -')] + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id') + ['' => ts('- prefix -')] + CRM_Contact_DAO_Contact::buildOptions('prefix_id') ); $form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name'] @@ -506,7 +506,7 @@ WHERE id={$contactId}; "; $attributes['last_name'] ); $form->addElement('select', 'suffix_id', ts('Suffix'), - ['' => ts('- suffix -')] + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id') + ['' => ts('- suffix -')] + CRM_Contact_DAO_Contact::buildOptions('suffix_id') ); } diff --git a/CRM/Contact/BAO/Individual.php b/CRM/Contact/BAO/Individual.php index ae8b21068b4..0ef40f3a1cf 100644 --- a/CRM/Contact/BAO/Individual.php +++ b/CRM/Contact/BAO/Individual.php @@ -277,8 +277,8 @@ class CRM_Contact_BAO_Individual extends CRM_Contact_DAO_Contact { * the constructed display name */ public function displayName() { - $prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'); - $suffix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id'); + $prefix = CRM_Contact_DAO_Contact::buildOptions('prefix_id'); + $suffix = CRM_Contact_DAO_Contact::buildOptions('suffix_id'); return str_replace(' ', ' ', trim($prefix[$this->prefix_id] . ' ' . $this->first_name . ' ' . $this->middle_name . ' ' . $this->last_name . ' ' . $suffix[$this->suffix_id])); } diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index effe302745e..72099cedd0e 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -3784,7 +3784,7 @@ WHERE $smartGroupClause $this->_tables['civicrm_address'] = 1; $this->_whereTables['civicrm_address'] = 1; - $locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); + $locationType = CRM_Core_DAO_Address::buildOptions('location_type_id'); $names = []; foreach ($value as $id) { $names[] = $locationType[$id]; @@ -6033,7 +6033,7 @@ AND displayRelType.is_active = 1 $viewValues = explode(CRM_Core_DAO::VALUE_SEPARATOR, $val); if ($value['pseudoField'] == 'participant_role') { - $pseudoOptions = CRM_Core_PseudoConstant::get('CRM_Event_DAO_Participant', 'role_id'); + $pseudoOptions = CRM_Event_DAO_Participant::buildOptions('role_id'); foreach ($viewValues as $k => $v) { $viewValues[$k] = $pseudoOptions[$v]; } diff --git a/CRM/Contact/Form/Contact.php b/CRM/Contact/Form/Contact.php index d009c554801..da99044c5f3 100644 --- a/CRM/Contact/Form/Contact.php +++ b/CRM/Contact/Form/Contact.php @@ -418,7 +418,7 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { * @param array $defaults */ public function blockSetDefaults(&$defaults) { - $locationTypeKeys = array_filter(array_keys(CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id')), 'is_int'); + $locationTypeKeys = array_filter(array_keys(CRM_Core_DAO_Address::buildOptions('location_type_id')), 'is_int'); sort($locationTypeKeys); // get the default location type diff --git a/CRM/Contact/Form/Edit/OpenID.php b/CRM/Contact/Form/Edit/OpenID.php index 0a123aba3f7..c7633b6e47b 100644 --- a/CRM/Contact/Form/Edit/OpenID.php +++ b/CRM/Contact/Form/Edit/OpenID.php @@ -45,7 +45,7 @@ class CRM_Contact_Form_Edit_OpenID { $form->addRule("openid[$blockId][openid]", ts('OpenID is not a valid URL.'), 'url'); //Block type - $form->addElement('select', "openid[$blockId][location_type_id]", '', CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id')); + $form->addElement('select', "openid[$blockId][location_type_id]", '', CRM_Core_DAO_Address::buildOptions('location_type_id')); //is_Primary radio $js = ['id' => "OpenID_" . $blockId . "_IsPrimary"]; diff --git a/CRM/Contact/Form/RelatedContact.php b/CRM/Contact/Form/RelatedContact.php index 94ffae0bceb..21a22eddcf2 100644 --- a/CRM/Contact/Form/RelatedContact.php +++ b/CRM/Contact/Form/RelatedContact.php @@ -153,7 +153,7 @@ class CRM_Contact_Form_RelatedContact extends CRM_Core_Form { default: // individual $form->addElement('select', 'prefix_id', ts('Prefix'), - ['' => ts('- prefix -')] + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id') + ['' => ts('- prefix -')] + CRM_Contact_DAO_Contact::buildOptions('prefix_id') ); $form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name'] @@ -165,7 +165,7 @@ class CRM_Contact_Form_RelatedContact extends CRM_Core_Form { $attributes['last_name'] ); $form->addElement('select', 'suffix_id', ts('Suffix'), - ['' => ts('- suffix -')] + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id') + ['' => ts('- suffix -')] + CRM_Contact_DAO_Contact::buildOptions('suffix_id') ); } diff --git a/CRM/Contact/Form/Search/Builder.php b/CRM/Contact/Form/Search/Builder.php index 2cdf2d64a27..1500d3bb6c2 100644 --- a/CRM/Contact/Form/Search/Builder.php +++ b/CRM/Contact/Form/Search/Builder.php @@ -593,7 +593,7 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search { } } - $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); + $locationTypes = CRM_Core_DAO_Address::buildOptions('location_type_id'); $defaultLocationType = CRM_Core_BAO_LocationType::getDefault(); @@ -628,8 +628,8 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search { $sel3[''] = NULL; $sel5[''] = NULL; - $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); - $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'); + $phoneTypes = CRM_Core_DAO_Phone::buildOptions('phone_type_id'); + $imProviders = CRM_Core_DAO_IM::buildOptions('provider_id'); asort($phoneTypes); foreach ($sel1 as $k => $sel) { diff --git a/CRM/Contact/Form/Search/Criteria.php b/CRM/Contact/Form/Search/Criteria.php index b939ee34f0d..29cd537fb4a 100644 --- a/CRM/Contact/Form/Search/Criteria.php +++ b/CRM/Contact/Form/Search/Criteria.php @@ -233,8 +233,8 @@ class CRM_Contact_Form_Search_Criteria { // Phone search $form->addElement('text', 'phone_numeric', ts('Phone'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone')); - $locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); - $phoneType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); + $locationType = CRM_Core_DAO_Address::buildOptions('location_type_id'); + $phoneType = CRM_Core_DAO_Phone::buildOptions('phone_type_id'); $form->add('select', 'phone_location_type_id', ts('Phone Location'), ['' => ts('- any -')] + $locationType, FALSE, ['class' => 'crm-select2']); $form->add('select', 'phone_phone_type_id', ts('Phone Type'), ['' => ts('- any -')] + $phoneType, FALSE, ['class' => 'crm-select2']); } @@ -480,7 +480,7 @@ class CRM_Contact_Form_Search_Criteria { $form->addSelect('world_region', ['entity' => 'address', 'context' => 'search']); // select for location type - $locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); + $locationType = CRM_Core_DAO_Address::buildOptions('location_type_id'); $form->add('select', 'location_type', ts('Address Location'), $locationType, FALSE, [ 'multiple' => TRUE, 'class' => 'crm-select2', @@ -563,7 +563,7 @@ class CRM_Contact_Form_Search_Criteria { $form->addFormFieldsFromMetadata(); // radio button for gender $genderOptionsAttributes = []; - $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'); + $gender = CRM_Contact_DAO_Contact::buildOptions('gender_id'); foreach ($gender as $key => $var) { $genderOptionsAttributes[$key] = ['id' => "civicrm_gender_{$var}_{$key}"]; } diff --git a/CRM/Contact/Form/Task/Label.php b/CRM/Contact/Form/Task/Label.php index 04b1fb732fe..6bc47734305 100644 --- a/CRM/Contact/Form/Task/Label.php +++ b/CRM/Contact/Form/Task/Label.php @@ -52,7 +52,7 @@ class CRM_Contact_Form_Task_Label extends CRM_Contact_Form_Task { $form->addElement('select', 'location_type_id', ts('Select Location'), [ '' => ts('Primary'), - ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'), TRUE + ] + CRM_Core_DAO_Address::buildOptions('location_type_id'), TRUE ); // checkbox for SKIP contacts with Do Not Mail privacy option @@ -144,7 +144,7 @@ class CRM_Contact_Form_Task_Label extends CRM_Contact_Form_Task { //get the contacts information $params = []; if (!empty($fv['location_type_id'])) { - $locType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); + $locType = CRM_Core_DAO_Address::buildOptions('location_type_id'); $locName = $locType[$fv['location_type_id']]; $location = ['location' => ["{$locName}" => $addressReturnProperties]]; $returnProperties = array_merge($returnProperties, $location); @@ -233,7 +233,7 @@ class CRM_Contact_Form_Task_Label extends CRM_Contact_Form_Task { $commMethods = $row['preferred_communication_method'] ?? NULL; if ($commMethods) { $val = array_filter(explode(CRM_Core_DAO::VALUE_SEPARATOR, $commMethods)); - $comm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method'); + $comm = CRM_Contact_DAO_Contact::buildOptions('preferred_communication_method'); $temp = []; foreach ($val as $vals) { $temp[] = $comm[$vals]; diff --git a/CRM/Contact/Form/Task/LabelCommon.php b/CRM/Contact/Form/Task/LabelCommon.php index 31c9b3add49..35acf85ec7a 100644 --- a/CRM/Contact/Form/Task/LabelCommon.php +++ b/CRM/Contact/Form/Task/LabelCommon.php @@ -118,7 +118,7 @@ class CRM_Contact_Form_Task_LabelCommon { $params[] = ['is_deceased', '=', 0, 0, 0]; if ($locationTypeID) { - $locType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); + $locType = CRM_Core_DAO_Address::buildOptions('location_type_id'); $locName = $locType[$locationTypeID]; $location = ['location' => ["{$locName}" => $addressReturnProperties]]; $returnProperties = array_merge($returnProperties, $location); diff --git a/CRM/Contact/Import/Form/MapField.php b/CRM/Contact/Import/Form/MapField.php index c0424febb7d..c7eccc75688 100644 --- a/CRM/Contact/Import/Form/MapField.php +++ b/CRM/Contact/Import/Form/MapField.php @@ -106,9 +106,9 @@ class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField { $sel1 = $this->_mapperFields; $sel2[''] = NULL; - $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); - $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'); - $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'); + $phoneTypes = CRM_Core_DAO_Phone::buildOptions('phone_type_id'); + $imProviders = CRM_Core_DAO_IM::buildOptions('provider_id'); + $websiteTypes = CRM_Core_DAO_Website::buildOptions('website_type_id'); foreach ($this->getLocationTypes() as $key => $value) { $sel3['phone'][$key] = &$phoneTypes; @@ -432,7 +432,7 @@ class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField { * @return array */ protected function getLocationTypes(): array { - return ['Primary' => ts('Primary')] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); + return ['Primary' => ts('Primary')] + CRM_Core_DAO_Address::buildOptions('location_type_id'); } /** diff --git a/CRM/Contact/Page/Inline/CommunicationPreferences.php b/CRM/Contact/Page/Inline/CommunicationPreferences.php index 4c4ca420540..7b994a28032 100644 --- a/CRM/Contact/Page/Inline/CommunicationPreferences.php +++ b/CRM/Contact/Page/Inline/CommunicationPreferences.php @@ -37,7 +37,7 @@ class CRM_Contact_Page_Inline_CommunicationPreferences extends CRM_Core_Page { CRM_Contact_BAO_Contact::getValues($params, $defaults); $defaults['privacy_values'] = CRM_Core_SelectValues::privacy(); - $communicationStyle = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id'); + $communicationStyle = CRM_Contact_DAO_Contact::buildOptions('communication_style_id'); if (!empty($communicationStyle)) { if (!empty($defaults['communication_style_id'])) { $defaults['communication_style_display'] = $communicationStyle[$defaults['communication_style_id']]; diff --git a/CRM/Contact/Page/Inline/Demographics.php b/CRM/Contact/Page/Inline/Demographics.php index e3a714872fb..f12ad625c4b 100644 --- a/CRM/Contact/Page/Inline/Demographics.php +++ b/CRM/Contact/Page/Inline/Demographics.php @@ -35,7 +35,7 @@ class CRM_Contact_Page_Inline_Demographics extends CRM_Core_Page { CRM_Contact_BAO_Contact::getValues($params, $defaults); if (!empty($defaults['gender_id'])) { - $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'); + $gender = CRM_Contact_DAO_Contact::buildOptions('gender_id'); $defaults['gender_display'] = $gender[$defaults['gender_id']]; } $this->assignFieldMetadataToTemplate('Contact'); diff --git a/CRM/Contact/Page/Inline/IM.php b/CRM/Contact/Page/Inline/IM.php index e20782a3265..738b017580a 100644 --- a/CRM/Contact/Page/Inline/IM.php +++ b/CRM/Contact/Page/Inline/IM.php @@ -30,7 +30,7 @@ class CRM_Contact_Page_Inline_IM extends CRM_Core_Page { $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE); $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', ['labelColumn' => 'display_name']); - $IMProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'); + $IMProviders = CRM_Core_DAO_IM::buildOptions('provider_id'); $entityBlock = ['contact_id' => $contactId]; $ims = CRM_Core_BAO_IM::getValues($entityBlock); diff --git a/CRM/Contact/Page/Inline/Phone.php b/CRM/Contact/Page/Inline/Phone.php index 714c1c039dd..bd62f1024f7 100644 --- a/CRM/Contact/Page/Inline/Phone.php +++ b/CRM/Contact/Page/Inline/Phone.php @@ -32,7 +32,7 @@ class CRM_Contact_Page_Inline_Phone extends CRM_Core_Page { $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE); $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', ['labelColumn' => 'display_name']); - $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); + $phoneTypes = CRM_Core_DAO_Phone::buildOptions('phone_type_id'); $entityBlock = ['contact_id' => $contactId]; $phones = CRM_Core_BAO_Phone::getValues($entityBlock); diff --git a/CRM/Contact/Page/Inline/Website.php b/CRM/Contact/Page/Inline/Website.php index de416295df8..b29695d6989 100644 --- a/CRM/Contact/Page/Inline/Website.php +++ b/CRM/Contact/Page/Inline/Website.php @@ -31,7 +31,7 @@ class CRM_Contact_Page_Inline_Website extends CRM_Core_Page { // get the emails for this contact $contactId = CRM_Utils_Request::retrieveValue('cid', 'Positive'); - $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'); + $websiteTypes = CRM_Core_DAO_Website::buildOptions('website_type_id'); $params = ['contact_id' => $contactId]; $websites = CRM_Core_BAO_Website::getValues($params); diff --git a/CRM/Contact/Page/View/Summary.php b/CRM/Contact/Page/View/Summary.php index 79f3b44e7ce..0ff3516146d 100644 --- a/CRM/Contact/Page/View/Summary.php +++ b/CRM/Contact/Page/View/Summary.php @@ -220,7 +220,7 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View { $defaults['gender_display'] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', 'gender_id', $defaults['gender_id'] ?? NULL); - $communicationStyle = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id'); + $communicationStyle = CRM_Contact_DAO_Contact::buildOptions('communication_style_id'); if (!empty($communicationStyle)) { if (!empty($defaults['communication_style_id'])) { $defaults['communication_style_display'] = $communicationStyle[$defaults['communication_style_id']]; diff --git a/CRM/Contact/Selector.php b/CRM/Contact/Selector.php index 509759be03d..045ddc3b8af 100644 --- a/CRM/Contact/Selector.php +++ b/CRM/Contact/Selector.php @@ -602,7 +602,7 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se } if ($this->_ufGroupID) { - $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); + $locationTypes = CRM_Core_DAO_Address::buildOptions('location_type_id'); $names = []; static $skipFields = ['group', 'tag']; @@ -690,7 +690,7 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se elseif (strpos($property, '-im')) { $row[$property] = $result->$property; if (!empty($result->$property)) { - $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'); + $imProviders = CRM_Core_DAO_IM::buildOptions('provider_id'); $providerId = $property . "-provider_id"; $providerName = $imProviders[$result->$providerId]; $row[$property] = $result->$property . " ({$providerName})"; @@ -716,7 +716,7 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se $propertyArray = explode('-', $property); $websiteFld = $websiteKey . '-' . array_pop($propertyArray); if (!empty($result->$websiteFld)) { - $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'); + $websiteTypes = CRM_Core_DAO_Website::buildOptions('website_type_id'); $websiteType = $websiteTypes[$result->{"$websiteKey-website_type_id"}]; $websiteValue = $result->$websiteFld; $websiteUrl = "<a href=\"{$websiteValue}\">{$websiteValue} ({$websiteType})</a>"; diff --git a/CRM/Contribute/BAO/ContributionSoft.php b/CRM/Contribute/BAO/ContributionSoft.php index 6da9fe81314..b6b29cd7a56 100644 --- a/CRM/Contribute/BAO/ContributionSoft.php +++ b/CRM/Contribute/BAO/ContributionSoft.php @@ -634,7 +634,7 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio case 'Individual': if (array_key_exists('prefix_id', $params)) { $honorName = CRM_Utils_Array::value($params['prefix_id'], - CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id') + CRM_Contact_DAO_Contact::buildOptions('prefix_id') ); unset($profileFields['prefix_id']); } @@ -643,7 +643,7 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio unset($profileFields['last_name']); if (array_key_exists('suffix_id', $params)) { $honorName .= ' ' . CRM_Utils_Array::value($params['suffix_id'], - CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id') + CRM_Contact_DAO_Contact::buildOptions('suffix_id') ); unset($profileFields['suffix_id']); } diff --git a/CRM/Core/BAO/Address.php b/CRM/Core/BAO/Address.php index 70161a145a6..27f30690ad4 100644 --- a/CRM/Core/BAO/Address.php +++ b/CRM/Core/BAO/Address.php @@ -387,7 +387,7 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address implements Civi\Core\Hoo $address->find(); - $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); + $locationTypes = CRM_Core_DAO_Address::buildOptions('location_type_id'); $count = 1; while ($address->fetch()) { // deprecate reference. diff --git a/CRM/Core/BAO/LocationType.php b/CRM/Core/BAO/LocationType.php index 55290124f64..f48fc5eaa72 100644 --- a/CRM/Core/BAO/LocationType.php +++ b/CRM/Core/BAO/LocationType.php @@ -70,7 +70,7 @@ class CRM_Core_BAO_LocationType extends CRM_Core_DAO_LocationType implements \Ci */ public static function getBilling() { if (self::$_billingLocationType == NULL) { - $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', [], 'validate'); + $locationTypes = CRM_Core_DAO_Address::buildOptions('location_type_id', 'validate'); self::$_billingLocationType = array_search('Billing', $locationTypes); } return self::$_billingLocationType; diff --git a/CRM/Core/BAO/Phone.php b/CRM/Core/BAO/Phone.php index f34f4c80d6c..00f8c76ea47 100644 --- a/CRM/Core/BAO/Phone.php +++ b/CRM/Core/BAO/Phone.php @@ -159,7 +159,7 @@ ORDER BY civicrm_phone.is_primary DESC, phone_id ASC "; $cond = NULL; if ($type) { - $phoneTypeId = array_search($type, CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id')); + $phoneTypeId = array_search($type, CRM_Core_DAO_Phone::buildOptions('phone_type_id')); if ($phoneTypeId) { $cond = " AND civicrm_phone.phone_type_id = $phoneTypeId"; } diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index cbcb5683e91..3a5d312b8f1 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -211,7 +211,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup implements \Civi\Core\Ho $fields = $subset; } else { - $ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); + $ufGroups = CRM_Core_DAO_UFField::buildOptions('uf_group_id'); $fields = []; foreach ($ufGroups as $id => $title) { @@ -1873,12 +1873,12 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $providerName = substr($name, 0, -1) . '-provider_id]'; } $form->add('select', $providerName, NULL, - CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'), $required + CRM_Core_DAO_IM::buildOptions('provider_id'), $required ); } else { $form->add('select', $name . '-provider_id', $title, - CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'), $required + CRM_Core_DAO_IM::buildOptions('provider_id'), $required ); } @@ -1979,7 +1979,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) ); } elseif ($fieldName === 'preferred_communication_method') { - $communicationFields = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method'); + $communicationFields = CRM_Contact_DAO_Contact::buildOptions('preferred_communication_method'); foreach ($communicationFields as $key => $var) { if ($key == '') { continue; @@ -2434,7 +2434,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) */ public static function getProfiles($types, $onlyPure = FALSE) { $profiles = []; - $ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); + $ufGroups = CRM_Core_DAO_UFField::buildOptions('uf_group_id'); CRM_Utils_Hook::aclGroup(CRM_Core_Permission::ADMIN, NULL, 'civicrm_uf_group', $ufGroups, $ufGroups); @@ -2468,7 +2468,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) } $profiles = []; - $ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); + $ufGroups = CRM_Core_DAO_UFField::buildOptions('uf_group_id'); CRM_Utils_Hook::aclGroup(CRM_Core_Permission::ADMIN, NULL, 'civicrm_uf_group', $ufGroups, $ufGroups); diff --git a/CRM/Core/Page/Basic.php b/CRM/Core/Page/Basic.php index 355e764841a..d4f3e727191 100644 --- a/CRM/Core/Page/Basic.php +++ b/CRM/Core/Page/Basic.php @@ -426,7 +426,7 @@ abstract class CRM_Core_Page_Basic extends CRM_Core_Page { $this->action($object, $action, $values[$object->id], $links, $permission); if (isset($object->mapping_type_id)) { - $mappintTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Mapping', 'mapping_type_id'); + $mappintTypes = CRM_Core_DAO_Mapping::buildOptions('mapping_type_id'); $values[$object->id]['mapping_type'] = $mappintTypes[$object->mapping_type_id]; } } diff --git a/CRM/Core/Permission.php b/CRM/Core/Permission.php index cbc50c68bc7..161a3edaeee 100644 --- a/CRM/Core/Permission.php +++ b/CRM/Core/Permission.php @@ -306,7 +306,7 @@ class CRM_Core_Permission { * @return array */ public static function ufGroup($type = CRM_Core_Permission::VIEW) { - $ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); + $ufGroups = CRM_Core_DAO_UFField::buildOptions('uf_group_id'); $allGroups = array_keys($ufGroups); diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 2500801f9d7..051cceb2d8e 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -1353,7 +1353,7 @@ WHERE civicrm_event.is_active = 1 $groupTitle['groupTitle'] = CRM_Core_BAO_UFGroup::getFrontEndTitle((int) $gid); } - $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'); + $imProviders = CRM_Core_DAO_IM::buildOptions('provider_id'); //start of code to set the default values foreach ($fields as $name => $field) { $customVal = ''; @@ -1409,7 +1409,7 @@ WHERE civicrm_event.is_active = 1 $values[$index] = $greeting[$params[$name]]; } elseif ($name === 'preferred_communication_method') { - $communicationFields = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method'); + $communicationFields = CRM_Contact_DAO_Contact::buildOptions('preferred_communication_method'); $compref = []; $pref = $params[$name]; if (is_array($pref)) { diff --git a/CRM/Event/Form/ManageEvent.php b/CRM/Event/Form/ManageEvent.php index b785cea2c60..cabaa5b04ee 100644 --- a/CRM/Event/Form/ManageEvent.php +++ b/CRM/Event/Form/ManageEvent.php @@ -159,7 +159,7 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form { $this->assign('isRepeatingEntity', $this->_isRepeatingEvent); // CRM-16776 - show edit/copy/create buttons for Profiles if user has required permission. - $ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); + $ufGroups = CRM_Core_DAO_UFField::buildOptions('uf_group_id'); $ufCreate = CRM_ACL_API::group(CRM_Core_Permission::CREATE, NULL, 'civicrm_uf_group', $ufGroups); $ufEdit = CRM_ACL_API::group(CRM_Core_Permission::EDIT, NULL, 'civicrm_uf_group', $ufGroups); $checkPermission = [ diff --git a/CRM/Event/Page/EventInfo.php b/CRM/Event/Page/EventInfo.php index 6c1eaeadfb4..49c4cab71ce 100644 --- a/CRM/Event/Page/EventInfo.php +++ b/CRM/Event/Page/EventInfo.php @@ -152,7 +152,7 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page { // fix phone type labels if (!empty($values['location']['phone'])) { - $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); + $phoneTypes = CRM_Core_DAO_Phone::buildOptions('phone_type_id'); foreach ($values['location']['phone'] as &$val) { if (!empty($val['phone_type_id'])) { $val['phone_type_display'] = $phoneTypes[$val['phone_type_id']]; diff --git a/CRM/Export/BAO/ExportProcessor.php b/CRM/Export/BAO/ExportProcessor.php index 1e935d9ce62..80ec7221fab 100644 --- a/CRM/Export/BAO/ExportProcessor.php +++ b/CRM/Export/BAO/ExportProcessor.php @@ -977,7 +977,7 @@ class CRM_Export_BAO_ExportProcessor { if ($this->isHouseholdToSkip($iterationDAO->contact_id)) { return FALSE; } - $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'); + $imProviders = CRM_Core_DAO_IM::buildOptions('provider_id'); $row = []; $householdMergeRelationshipType = $this->getHouseholdMergeTypeForRow($iterationDAO->contact_id); @@ -2122,8 +2122,8 @@ WHERE id IN ( $deleteIDString ) * @throws \Exception */ public function fetchRelationshipDetails($relDAO, $value, $field, &$row) { - $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); - $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'); + $phoneTypes = CRM_Core_DAO_Phone::buildOptions('phone_type_id'); + $imProviders = CRM_Core_DAO_IM::buildOptions('provider_id'); $i18n = CRM_Core_I18n::singleton(); $field = $field . '_'; diff --git a/CRM/Financial/BAO/EntityFinancialAccount.php b/CRM/Financial/BAO/EntityFinancialAccount.php index 41f4f5b0691..0a3bdf7ba59 100644 --- a/CRM/Financial/BAO/EntityFinancialAccount.php +++ b/CRM/Financial/BAO/EntityFinancialAccount.php @@ -96,7 +96,7 @@ class CRM_Financial_BAO_EntityFinancialAccount extends CRM_Financial_DAO_EntityF // check if financial type is present $check = FALSE; - $relationValues = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship'); + $relationValues = CRM_Financial_DAO_EntityFinancialAccount::buildOptions('account_relationship'); $financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_EntityFinancialAccount', $financialTypeAccountId, 'entity_id'); // check dependencies @@ -266,7 +266,7 @@ class CRM_Financial_BAO_EntityFinancialAccount extends CRM_Financial_DAO_EntityF $financialAccountLinks = CRM_Financial_BAO_FinancialAccount::getfinancialAccountRelations(); $financialAccountType = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialAccount', $financialTypeAccount->financial_account_id, 'financial_account_type_id'); if (($financialAccountLinks[$financialTypeAccount->account_relationship] ?? NULL) != $financialAccountType) { - $accountRelationships = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship'); + $accountRelationships = CRM_Financial_DAO_EntityFinancialAccount::buildOptions('account_relationship'); throw new CRM_Core_Exception(ts("This financial account cannot have '%1' relationship.", [1 => $accountRelationships[$financialTypeAccount->account_relationship]])); } } diff --git a/CRM/Financial/BAO/FinancialItem.php b/CRM/Financial/BAO/FinancialItem.php index d46e6be7f98..8d06731c411 100644 --- a/CRM/Financial/BAO/FinancialItem.php +++ b/CRM/Financial/BAO/FinancialItem.php @@ -43,7 +43,7 @@ class CRM_Financial_BAO_FinancialItem extends CRM_Financial_DAO_FinancialItem { * @return CRM_Financial_DAO_FinancialItem */ public static function add($lineItem, $contribution, $taxTrxnID = FALSE, $trxnId = NULL) { - $financialItemStatus = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialItem', 'status_id'); + $financialItemStatus = CRM_Financial_DAO_FinancialItem::buildOptions('status_id'); $contributionStatus = CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $contribution->contribution_status_id); $itemStatus = NULL; if ($contributionStatus === 'Completed' || $contributionStatus === 'Pending refund') { diff --git a/CRM/Financial/Form/FinancialAccount.php b/CRM/Financial/Form/FinancialAccount.php index 9af95e9c42e..32972bd4067 100644 --- a/CRM/Financial/Form/FinancialAccount.php +++ b/CRM/Financial/Form/FinancialAccount.php @@ -102,7 +102,7 @@ class CRM_Financial_Form_FinancialAccount extends CRM_Contribute_Form { $element->freeze(); } - $financialAccountType = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialAccount', 'financial_account_type_id'); + $financialAccountType = CRM_Financial_DAO_FinancialAccount::buildOptions('financial_account_type_id'); if (!empty($financialAccountType)) { $element = $this->add('select', 'financial_account_type_id', ts('Financial Account Type'), ['' => ts('- select -')] + $financialAccountType, TRUE, ['class' => 'crm-select2 huge']); diff --git a/CRM/Financial/Form/FinancialBatch.php b/CRM/Financial/Form/FinancialBatch.php index fbcf4bb3c78..4dcb4ab59c4 100644 --- a/CRM/Financial/Form/FinancialBatch.php +++ b/CRM/Financial/Form/FinancialBatch.php @@ -85,7 +85,7 @@ class CRM_Financial_Form_FinancialBatch extends CRM_Contribute_Form { ); if ($this->_action & CRM_Core_Action::UPDATE && $this->_id) { - $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_BAO_Batch', 'status_id'); + $batchStatus = CRM_Batch_BAO_Batch::buildOptions('status_id'); // unset exported status $exportedStatusId = CRM_Core_PseudoConstant::getKey('CRM_Batch_BAO_Batch', 'status_id', 'Exported'); diff --git a/CRM/Financial/Form/FinancialTypeAccount.php b/CRM/Financial/Form/FinancialTypeAccount.php index b28b57360ea..e59f325f702 100644 --- a/CRM/Financial/Form/FinancialTypeAccount.php +++ b/CRM/Financial/Form/FinancialTypeAccount.php @@ -211,7 +211,7 @@ class CRM_Financial_Form_FinancialTypeAccount extends CRM_Core_Form { $errorMsg = []; $errorFlag = FALSE; if ($self->_action == CRM_Core_Action::DELETE) { - $relationValues = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship'); + $relationValues = CRM_Financial_DAO_EntityFinancialAccount::buildOptions('account_relationship'); if (($values['financial_account_id'] ?? NULL) != 'select') { if ($relationValues[$values['account_relationship']] == 'Premiums Inventory Account is' || $relationValues[$values['account_relationship']] == 'Cost of Sales Account is') { $premiumsProduct = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PremiumsProduct', $values['financial_type_id'], 'product_id', 'financial_type_id'); diff --git a/CRM/Financial/Page/FinancialAccount.php b/CRM/Financial/Page/FinancialAccount.php index a286705b2e6..4b3b2043a06 100644 --- a/CRM/Financial/Page/FinancialAccount.php +++ b/CRM/Financial/Page/FinancialAccount.php @@ -87,7 +87,7 @@ class CRM_Financial_Page_FinancialAccount extends CRM_Core_Page_Basic { $dao = new CRM_Financial_DAO_FinancialAccount(); $dao->orderBy('financial_account_type_id, name'); $dao->find(); - $financialAccountType = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialAccount', 'financial_account_type_id'); + $financialAccountType = CRM_Financial_DAO_FinancialAccount::buildOptions('financial_account_type_id'); while ($dao->fetch()) { $contributionType[$dao->id] = []; diff --git a/CRM/Financial/Page/FinancialTypeAccount.php b/CRM/Financial/Page/FinancialTypeAccount.php index 53ff637fcc2..f82cf679fbb 100644 --- a/CRM/Financial/Page/FinancialTypeAccount.php +++ b/CRM/Financial/Page/FinancialTypeAccount.php @@ -114,8 +114,8 @@ class CRM_Financial_Page_FinancialTypeAccount extends CRM_Core_Page { $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' ")); $this->_title = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $this->_aid, 'name'); CRM_Utils_System::setTitle($this->_title . ' - ' . ts('Assigned Financial Accounts')); - $financialAccountType = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialAccount', 'financial_account_type_id'); - $accountRelationship = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship'); + $financialAccountType = CRM_Financial_DAO_FinancialAccount::buildOptions('financial_account_type_id'); + $accountRelationship = CRM_Financial_DAO_EntityFinancialAccount::buildOptions('account_relationship'); $dao->copyValues($params); $dao->find(); while ($dao->fetch()) { diff --git a/CRM/Import/Parser.php b/CRM/Import/Parser.php index b6fcee3e988..3ba297e0da9 100644 --- a/CRM/Import/Parser.php +++ b/CRM/Import/Parser.php @@ -1018,7 +1018,7 @@ abstract class CRM_Import_Parser implements UserJobInterface { if (isset($values['individual_prefix'])) { CRM_Core_Error::deprecatedWarning('code should be unreachable, slated for removal'); if (!empty($params['prefix_id'])) { - $prefixes = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'); + $prefixes = CRM_Contact_DAO_Contact::buildOptions('prefix_id'); $params['prefix'] = $prefixes[$params['prefix_id']]; } else { @@ -1030,7 +1030,7 @@ abstract class CRM_Import_Parser implements UserJobInterface { if (isset($values['individual_suffix'])) { CRM_Core_Error::deprecatedWarning('code should be unreachable, slated for removal'); if (!empty($params['suffix_id'])) { - $suffixes = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id'); + $suffixes = CRM_Contact_DAO_Contact::buildOptions('suffix_id'); $params['suffix'] = $suffixes[$params['suffix_id']]; } else { @@ -1042,7 +1042,7 @@ abstract class CRM_Import_Parser implements UserJobInterface { if (isset($values['gender'])) { CRM_Core_Error::deprecatedWarning('code should be unreachable, slated for removal'); if (!empty($params['gender_id'])) { - $genders = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'); + $genders = CRM_Contact_DAO_Contact::buildOptions('gender_id'); $params['gender'] = $genders[$params['gender_id']]; } else { diff --git a/CRM/Logging/Differ.php b/CRM/Logging/Differ.php index f7c587b1bbb..c995f80dc72 100644 --- a/CRM/Logging/Differ.php +++ b/CRM/Logging/Differ.php @@ -276,20 +276,20 @@ WHERE lt.log_conn_id = %1 'contribution_status_id' => CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label'), 'financial_type_id' => CRM_Contribute_PseudoConstant::financialType(), 'country_id' => CRM_Core_PseudoConstant::country(), - 'gender_id' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), - 'location_type_id' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'), + 'gender_id' => CRM_Contact_DAO_Contact::buildOptions('gender_id'), + 'location_type_id' => CRM_Core_DAO_Address::buildOptions('location_type_id'), 'payment_instrument_id' => CRM_Contribute_PseudoConstant::paymentInstrument(), - 'phone_type_id' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'), + 'phone_type_id' => CRM_Core_DAO_Phone::buildOptions('phone_type_id'), 'preferred_communication_method' => CRM_Contact_BAO_Contact::buildOptions('preferred_communication_method'), 'preferred_language' => CRM_Contact_BAO_Contact::buildOptions('preferred_language'), 'prefix_id' => CRM_Contact_BAO_Contact::buildOptions('prefix_id'), - 'provider_id' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'), + 'provider_id' => CRM_Core_DAO_IM::buildOptions('provider_id'), 'state_province_id' => CRM_Core_PseudoConstant::stateProvince(), 'suffix_id' => CRM_Contact_BAO_Contact::buildOptions('suffix_id'), - 'website_type_id' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'), + 'website_type_id' => CRM_Core_DAO_Website::buildOptions('website_type_id'), 'activity_type_id' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE), 'case_type_id' => CRM_Case_PseudoConstant::caseType('title', FALSE), - 'priority_id' => CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'), + 'priority_id' => CRM_Activity_DAO_Activity::buildOptions('priority_id'), 'record_type_id' => CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'get'), ]; diff --git a/CRM/Mailing/Form/Approve.php b/CRM/Mailing/Form/Approve.php index 78203d467ed..91b195e2924 100644 --- a/CRM/Mailing/Form/Approve.php +++ b/CRM/Mailing/Form/Approve.php @@ -77,7 +77,7 @@ class CRM_Mailing_Form_Approve extends CRM_Core_Form { $this->addElement('textarea', 'approval_note', ts('Approve/Reject Note')); - $mailApprovalStatus = CRM_Core_PseudoConstant::get('CRM_Mailing_BAO_Mailing', 'approval_status_id'); + $mailApprovalStatus = CRM_Mailing_BAO_Mailing::buildOptions('approval_status_id'); // eliminate the none option $noneOptionID = CRM_Core_PseudoConstant::getKey('CRM_Mailing_BAO_Mailing', 'approval_status_id', 'None'); diff --git a/CRM/Mailing/MailStore.php b/CRM/Mailing/MailStore.php index 1aa3e62b341..27f25d52a15 100644 --- a/CRM/Mailing/MailStore.php +++ b/CRM/Mailing/MailStore.php @@ -47,7 +47,7 @@ class CRM_Mailing_MailStore { throw new Exception("Could not find entry named $name in civicrm_mail_settings"); } - $protocols = CRM_Core_PseudoConstant::get('CRM_Core_DAO_MailSettings', 'protocol', [], 'validate'); + $protocols = CRM_Core_DAO_MailSettings::buildOptions('protocol', 'validate'); // Prepare normalized/hookable representation of the mail settings. $mailSettings = $dao->toArray(); diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index 19c442965c6..7162ae8fbff 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -208,8 +208,8 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { $resources->addScriptFile('civicrm', 'templates/CRM/Member/Form/MembershipStandalone.js'); $passthru = [ 'typeorgs' => CRM_Member_BAO_MembershipType::getMembershipTypeOrganization(), - 'memtypes' => CRM_Core_PseudoConstant::get('CRM_Member_BAO_Membership', 'membership_type_id'), - 'statuses' => CRM_Core_PseudoConstant::get('CRM_Member_BAO_Membership', 'status_id'), + 'memtypes' => CRM_Member_BAO_Membership::buildOptions('membership_type_id'), + 'statuses' => CRM_Member_BAO_Membership::buildOptions('status_id'), ]; $resources->addSetting(['existingMems' => $passthru]); } diff --git a/CRM/Member/Form/Task/Label.php b/CRM/Member/Form/Task/Label.php index cd00c233895..c21aa2f100c 100644 --- a/CRM/Member/Form/Task/Label.php +++ b/CRM/Member/Form/Task/Label.php @@ -94,7 +94,7 @@ class CRM_Member_Form_Task_Label extends CRM_Member_Form_Task { $commMethods = $row['preferred_communication_method'] ?? NULL; if ($commMethods) { $val = array_filter(explode(CRM_Core_DAO::VALUE_SEPARATOR, $commMethods)); - $comm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method'); + $comm = CRM_Contact_DAO_Contact::buildOptions('preferred_communication_method'); $temp = []; foreach ($val as $vals) { $temp[] = $comm[$vals]; diff --git a/CRM/PCP/BAO/PCP.php b/CRM/PCP/BAO/PCP.php index 6bc8112a663..feede0c47f3 100644 --- a/CRM/PCP/BAO/PCP.php +++ b/CRM/PCP/BAO/PCP.php @@ -504,7 +504,7 @@ WHERE pcp.id = %1 AND cc.contribution_status_id = %2 AND cc.is_test = 0"; return FALSE; } - $pcpStatus = CRM_Core_PseudoConstant::get('CRM_PCP_BAO_PCP', 'status_id'); + $pcpStatus = CRM_PCP_BAO_PCP::buildOptions('status_id'); $approvedId = array_search('Approved', $pcpStatus); $params = ['id' => $pcpId]; diff --git a/CRM/Profile/Form.php b/CRM/Profile/Form.php index b86c57065ca..8f9a89d9591 100644 --- a/CRM/Profile/Form.php +++ b/CRM/Profile/Form.php @@ -823,7 +823,7 @@ class CRM_Profile_Form extends CRM_Core_Form { CRM_Core_Permission::EDIT, NULL, 'civicrm_uf_group', - CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id') + CRM_Core_DAO_UFField::buildOptions('uf_group_id') ) ) ) { diff --git a/CRM/Profile/Selector/Listings.php b/CRM/Profile/Selector/Listings.php index 2f9aae2ab5c..36741ac35de 100644 --- a/CRM/Profile/Selector/Listings.php +++ b/CRM/Profile/Selector/Listings.php @@ -284,7 +284,7 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR ], ]; - $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); + $locationTypes = CRM_Core_DAO_Address::buildOptions('location_type_id'); foreach ($this->_fields as $name => $field) { // skip pseudo fields diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 34b7205fdf4..871ef2f8f82 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -2705,7 +2705,7 @@ class CRM_Report_Form extends CRM_Core_Form { * @return mixed */ protected function alterCommunicationtMethod($value, &$row, $fieldname) { - $communicationMethods = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method'); + $communicationMethods = CRM_Contact_DAO_Contact::buildOptions('preferred_communication_method'); // Explode padded values. $values = CRM_Utils_Array::explodePadded($value); @@ -4970,7 +4970,7 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a 'gender_id' => [ 'title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), + 'options' => CRM_Contact_DAO_Contact::buildOptions('gender_id'), ], 'birth_date' => [ 'title' => ts('Birth Date'), diff --git a/CRM/Report/Form/Activity.php b/CRM/Report/Form/Activity.php index 10b2ed14fb8..fba5f58c651 100644 --- a/CRM/Report/Form/Activity.php +++ b/CRM/Report/Form/Activity.php @@ -342,7 +342,7 @@ class CRM_Report_Form_Activity extends CRM_Report_Form { 'title' => ts('Activity Priority'), 'type' => CRM_Utils_Type::T_STRING, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'), + 'options' => CRM_Activity_DAO_Activity::buildOptions('priority_id'), ], ], 'order_bys' => [ @@ -932,8 +932,8 @@ GROUP BY civicrm_activity_id $having {$this->_orderBy}"; $entryFound = FALSE; $activityType = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE); $activityStatus = CRM_Core_PseudoConstant::activityStatus(); - $priority = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'); - $genders = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'); + $priority = CRM_Activity_DAO_Activity::buildOptions('priority_id'); + $genders = CRM_Contact_DAO_Contact::buildOptions('gender_id'); $viewLinks = FALSE; // Would we ever want to retrieve from the form controller?? diff --git a/CRM/Report/Form/ActivitySummary.php b/CRM/Report/Form/ActivitySummary.php index 32f1f5a78be..b162e9b4c99 100644 --- a/CRM/Report/Form/ActivitySummary.php +++ b/CRM/Report/Form/ActivitySummary.php @@ -142,7 +142,7 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { 'title' => ts('Activity Priority'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'), + 'options' => CRM_Activity_DAO_Activity::buildOptions('priority_id'), ], ], 'group_bys' => [ @@ -665,7 +665,7 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { $entryFound = FALSE; $activityType = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE); $activityStatus = CRM_Core_PseudoConstant::activityStatus(); - $priority = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'); + $priority = CRM_Activity_DAO_Activity::buildOptions('priority_id'); $onHover = ts('View Contact Summary for this Contact'); foreach ($rows as $rowNum => $row) { // make count columns point to activity detail report diff --git a/CRM/Report/Form/Contribute/History.php b/CRM/Report/Form/Contribute/History.php index 841e395a9ee..0c55519f9bb 100644 --- a/CRM/Report/Form/Contribute/History.php +++ b/CRM/Report/Form/Contribute/History.php @@ -148,7 +148,7 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { 'gender_id' => [ 'title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), + 'options' => CRM_Contact_DAO_Contact::buildOptions('gender_id'), ], 'birth_date' => [ 'title' => ts('Birth Date'), diff --git a/CRM/Report/Form/Contribute/Lybunt.php b/CRM/Report/Form/Contribute/Lybunt.php index ee3c8d808ea..81049c54487 100644 --- a/CRM/Report/Form/Contribute/Lybunt.php +++ b/CRM/Report/Form/Contribute/Lybunt.php @@ -109,7 +109,7 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { 'gender_id' => [ 'title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), + 'options' => CRM_Contact_DAO_Contact::buildOptions('gender_id'), ], 'birth_date' => [ 'title' => ts('Birth Date'), diff --git a/CRM/Report/Form/Contribute/SoftCredit.php b/CRM/Report/Form/Contribute/SoftCredit.php index 109af20c51f..4678ce8f22c 100644 --- a/CRM/Report/Form/Contribute/SoftCredit.php +++ b/CRM/Report/Form/Contribute/SoftCredit.php @@ -146,7 +146,7 @@ class CRM_Report_Form_Contribute_SoftCredit extends CRM_Report_Form { 'gender_id' => [ 'title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), + 'options' => CRM_Contact_DAO_Contact::buildOptions('gender_id'), ], 'birth_date' => [ 'title' => ts('Birth Date'), diff --git a/CRM/Report/Form/Contribute/Sybunt.php b/CRM/Report/Form/Contribute/Sybunt.php index 318e007cacc..72aae088076 100644 --- a/CRM/Report/Form/Contribute/Sybunt.php +++ b/CRM/Report/Form/Contribute/Sybunt.php @@ -133,7 +133,7 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { 'gender_id' => [ 'title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), + 'options' => CRM_Contact_DAO_Contact::buildOptions('gender_id'), ], 'birth_date' => [ 'title' => ts('Birth Date'), diff --git a/CRM/Report/Form/Event/ParticipantListCount.php b/CRM/Report/Form/Event/ParticipantListCount.php index 5f8bc165960..8c172c59fec 100644 --- a/CRM/Report/Form/Event/ParticipantListCount.php +++ b/CRM/Report/Form/Event/ParticipantListCount.php @@ -93,7 +93,7 @@ class CRM_Report_Form_Event_ParticipantListCount extends CRM_Report_Form { 'gender_id' => [ 'title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), + 'options' => CRM_Contact_DAO_Contact::buildOptions('gender_id'), ], 'birth_date' => [ 'title' => ts('Birth Date'), diff --git a/CRM/SMS/Provider.php b/CRM/SMS/Provider.php index 8828f5a6ac9..c4876d52be5 100644 --- a/CRM/SMS/Provider.php +++ b/CRM/SMS/Provider.php @@ -179,8 +179,8 @@ INNER JOIN civicrm_mailing_job mj ON mj.mailing_id = m.id AND mj.id = %1"; // unknown mobile sender -- create new contact // use fake @mobile.sms email address for new contact since civi // requires email or name for all contacts - $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); - $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); + $locationTypes = CRM_Core_DAO_Address::buildOptions('location_type_id'); + $phoneTypes = CRM_Core_DAO_Phone::buildOptions('phone_type_id'); $phoneloc = array_search('Home', $locationTypes); $phonetype = array_search('Mobile', $phoneTypes); $stripFrom = $this->stripPhone($message->from); diff --git a/CRM/UF/Form/Field.php b/CRM/UF/Form/Field.php index 0d7b7cb1810..68d0269421b 100644 --- a/CRM/UF/Form/Field.php +++ b/CRM/UF/Form/Field.php @@ -266,9 +266,9 @@ class CRM_UF_Form_Field extends CRM_Core_Form { } $this->assign('noSearchable', $noSearchable); - $this->_location_types = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); + $this->_location_types = CRM_Core_DAO_Address::buildOptions('location_type_id'); $defaultLocationType = CRM_Core_BAO_LocationType::getDefault(); - $this->_website_types = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'); + $this->_website_types = CRM_Core_DAO_Website::buildOptions('website_type_id'); /** * FIXME: dirty hack to make the default option show up first. This @@ -323,7 +323,7 @@ class CRM_UF_Form_Field extends CRM_Core_Form { } } $sel3[''] = NULL; - $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); + $phoneTypes = CRM_Core_DAO_Phone::buildOptions('phone_type_id'); ksort($phoneTypes); foreach ($sel1 as $k => $sel) { diff --git a/CRM/UF/Page/Field.php b/CRM/UF/Page/Field.php index 04ff5eb776c..8c236f17505 100644 --- a/CRM/UF/Page/Field.php +++ b/CRM/UF/Page/Field.php @@ -117,8 +117,7 @@ class CRM_UF_Page_Field extends CRM_Core_Page { $this->assign('skipCreate', TRUE); } - $locationType = []; - $locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); + $locationType = CRM_Core_DAO_Address::buildOptions('location_type_id'); $fields = CRM_Contact_BAO_Contact::exportableFields('All', FALSE, TRUE); $fields = array_merge(CRM_Contribute_BAO_Contribution::getContributionFields(), $fields); diff --git a/CRM/UF/Page/Group.php b/CRM/UF/Page/Group.php index 2f92e296291..9633e5c06ba 100644 --- a/CRM/UF/Page/Group.php +++ b/CRM/UF/Page/Group.php @@ -280,7 +280,7 @@ class CRM_UF_Page_Group extends CRM_Core_Page { return; } - $ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); + $ufGroups = CRM_Core_DAO_UFField::buildOptions('uf_group_id'); CRM_Utils_Hook::aclGroup(CRM_Core_Permission::ADMIN, NULL, 'civicrm_uf_group', $ufGroups, $allUFGroups); foreach ($allUFGroups as $id => $value) { diff --git a/CRM/UF/Page/ProfileEditor.php b/CRM/UF/Page/ProfileEditor.php index e68edee1698..ede55041d05 100644 --- a/CRM/UF/Page/ProfileEditor.php +++ b/CRM/UF/Page/ProfileEditor.php @@ -45,9 +45,9 @@ class CRM_UF_Page_ProfileEditor extends CRM_Core_Page { } return [ 'PseudoConstant' => [ - 'locationType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'), - 'websiteType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'), - 'phoneType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'), + 'locationType' => CRM_Core_DAO_Address::buildOptions('location_type_id'), + 'websiteType' => CRM_Core_DAO_Website::buildOptions('website_type_id'), + 'phoneType' => CRM_Core_DAO_Phone::buildOptions('phone_type_id'), ], 'initialProfileList' => $ufGroups, 'contactSubTypes' => CRM_Contact_BAO_ContactType::subTypes(), diff --git a/Civi/API/Subscriber/PermissionCheck.php b/Civi/API/Subscriber/PermissionCheck.php index 9441800733c..2801d067307 100644 --- a/Civi/API/Subscriber/PermissionCheck.php +++ b/Civi/API/Subscriber/PermissionCheck.php @@ -94,7 +94,7 @@ class PermissionCheck implements EventSubscriberInterface { switch ($apiRequest['entity']) { case 'UFGroup': case 'UFField': - $ufGroups = \CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); + $ufGroups = \CRM_Core_DAO_UFField::buildOptions('uf_group_id'); $aclCreate = \CRM_ACL_API::group(\CRM_Core_Permission::CREATE, NULL, 'civicrm_uf_group', $ufGroups); $aclEdit = \CRM_ACL_API::group(\CRM_Core_Permission::EDIT, NULL, 'civicrm_uf_group', $ufGroups); $ufGroupId = $apiRequest['entity'] == 'UFGroup' ? $apiRequest['params']['id'] : $apiRequest['params']['uf_group_id']; diff --git a/api/v3/Contact.php b/api/v3/Contact.php index 747b62f07e2..604571d16cc 100644 --- a/api/v3/Contact.php +++ b/api/v3/Contact.php @@ -69,7 +69,7 @@ function civicrm_api3_contact_create($params) { } if (!empty($params['home_url'])) { - $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'); + $websiteTypes = CRM_Core_DAO_Website::buildOptions('website_type_id'); $params['website'] = [ 1 => [ 'website_type_id' => key($websiteTypes), diff --git a/ext/civigrant/CRM/Grant/BAO/Grant.php b/ext/civigrant/CRM/Grant/BAO/Grant.php index abb03897753..9bec9b46e12 100644 --- a/ext/civigrant/CRM/Grant/BAO/Grant.php +++ b/ext/civigrant/CRM/Grant/BAO/Grant.php @@ -40,7 +40,7 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant implements \Civi\Core\Hook $status = []; $summary = []; $summary['total_grants'] = NULL; - $status = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id'); + $status = CRM_Grant_DAO_Grant::buildOptions('status_id'); foreach ($status as $id => $name) { $stats[$id] = [ diff --git a/ext/civigrant/CRM/Grant/Form/GrantView.php b/ext/civigrant/CRM/Grant/Form/GrantView.php index 85df01e9b54..d48f8077a69 100644 --- a/ext/civigrant/CRM/Grant/Form/GrantView.php +++ b/ext/civigrant/CRM/Grant/Form/GrantView.php @@ -30,8 +30,8 @@ class CRM_Grant_Form_GrantView extends CRM_Core_Form { ]; $values = []; CRM_Grant_BAO_Grant::retrieve($params, $values); - $grantType = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id'); - $grantStatus = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id'); + $grantType = CRM_Grant_DAO_Grant::buildOptions('grant_type_id'); + $grantStatus = CRM_Grant_DAO_Grant::buildOptions('status_id'); $this->assign('grantType', $grantType[$values['grant_type_id']]); $this->assign('grantStatus', $grantStatus[$values['status_id']]); $grantTokens = [ diff --git a/ext/civigrant/CRM/Grant/Form/Task/Update.php b/ext/civigrant/CRM/Grant/Form/Task/Update.php index 80514bc5b40..929398c4e80 100644 --- a/ext/civigrant/CRM/Grant/Form/Task/Update.php +++ b/ext/civigrant/CRM/Grant/Form/Task/Update.php @@ -43,7 +43,7 @@ class CRM_Grant_Form_Task_Update extends CRM_Grant_Form_Task { * @return void */ public function buildQuickForm() { - $grantStatus = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id'); + $grantStatus = CRM_Grant_DAO_Grant::buildOptions('status_id'); $this->addElement('select', 'status_id', ts('Grant Status'), ['' => ''] + $grantStatus); $this->addElement('text', 'amount_granted', ts('Amount Granted')); diff --git a/ext/civigrant/CRM/Report/Form/Grant/Detail.php b/ext/civigrant/CRM/Report/Form/Grant/Detail.php index ea561a0f6f1..704ef46957f 100644 --- a/ext/civigrant/CRM/Report/Form/Grant/Detail.php +++ b/ext/civigrant/CRM/Report/Form/Grant/Detail.php @@ -110,14 +110,14 @@ class CRM_Report_Form_Grant_Detail extends CRM_Report_Form { 'name' => 'grant_type_id', 'title' => ts('Grant Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id'), + 'options' => CRM_Grant_DAO_Grant::buildOptions('grant_type_id'), ], 'status_id' => [ 'name' => 'status_id', 'title' => ts('Grant Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id'), + 'options' => CRM_Grant_DAO_Grant::buildOptions('status_id'), ], 'amount_granted' => [ 'title' => ts('Amount Granted'), diff --git a/ext/civigrant/CRM/Report/Form/Grant/Statistics.php b/ext/civigrant/CRM/Report/Form/Grant/Statistics.php index 0ea5e629eaa..c377f0b88a3 100644 --- a/ext/civigrant/CRM/Report/Form/Grant/Statistics.php +++ b/ext/civigrant/CRM/Report/Form/Grant/Statistics.php @@ -83,14 +83,14 @@ class CRM_Report_Form_Grant_Statistics extends CRM_Report_Form { 'name' => 'grant_type_id', 'title' => ts('Grant Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id'), + 'options' => CRM_Grant_DAO_Grant::buildOptions('grant_type_id'), ], 'status_id' => [ 'name' => 'status_id', 'title' => ts('Grant Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id'), + 'options' => CRM_Grant_DAO_Grant::buildOptions('status_id'), ], 'amount_requested' => [ 'name' => 'amount_requested', @@ -134,7 +134,7 @@ class CRM_Report_Form_Grant_Statistics extends CRM_Report_Form { 'name' => 'gender_id', 'title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), + 'options' => CRM_Contact_DAO_Contact::buildOptions('gender_id'), ], 'contact_type' => [ 'name' => 'contact_type', @@ -335,9 +335,9 @@ WHERE {$this->_aliases['civicrm_grant']}.amount_total IS NOT NULL $awardedGrantsAmount = $grantsReceived = $totalAmount = $awardedGrants = $grantReportsReceived = 0; $grantStatistics = []; - $grantTypes = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id'); + $grantTypes = CRM_Grant_DAO_Grant::buildOptions('grant_type_id'); $countries = CRM_Core_PseudoConstant::country(); - $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'); + $gender = CRM_Contact_DAO_Contact::buildOptions('gender_id'); $grantAmountTotal = " SELECT COUNT({$this->_aliases['civicrm_grant']}.id) as count , diff --git a/tests/phpunit/CRM/Contact/BAO/ContactTest.php b/tests/phpunit/CRM/Contact/BAO/ContactTest.php index c9b9c4a3890..fcfc09a6eec 100644 --- a/tests/phpunit/CRM/Contact/BAO/ContactTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ContactTest.php @@ -1163,8 +1163,8 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { //get display name. $dbDisplayName = CRM_Contact_BAO_Contact::displayName($contactId); - $prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'); - $suffix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id'); + $prefix = CRM_Contact_DAO_Contact::buildOptions('prefix_id'); + $suffix = CRM_Contact_DAO_Contact::buildOptions('suffix_id'); //build display name $paramsDisplayName = $prefix[$params['prefix_id']] . ' ' . $params['first_name'] . ' ' . $params['last_name'] . ' ' . $suffix[$params['suffix_id']]; @@ -1192,8 +1192,8 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { $checkImage = CRM_Contact_BAO_Contact_Utils::getImage($params['contact_type'], FALSE, $contactId); - $prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'); - $suffix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id'); + $prefix = CRM_Contact_DAO_Contact::buildOptions('prefix_id'); + $suffix = CRM_Contact_DAO_Contact::buildOptions('suffix_id'); //build display name $paramsDisplayName = $prefix[$params['prefix_id']] . ' ' . $params['first_name'] . ' ' . $params['last_name'] . ' ' . $suffix[$params['suffix_id']]; -- GitLab