From bd8e0b1475ebc12a11dcdbc8b4b4dacff12a1746 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 28 Jul 2016 15:10:30 -0700 Subject: [PATCH] Regen DAOs with new fieldKeys() --- CRM/ACL/DAO/ACL.php | 28 ++----- CRM/ACL/DAO/Cache.php | 21 ++--- CRM/ACL/DAO/EntityRole.php | 22 ++--- CRM/Activity/DAO/Activity.php | 41 ++-------- CRM/Activity/DAO/ActivityContact.php | 21 ++--- CRM/Batch/DAO/Batch.php | 34 ++------ CRM/Batch/DAO/EntityBatch.php | 21 ++--- CRM/Campaign/DAO/Campaign.php | 34 ++------ CRM/Campaign/DAO/CampaignGroup.php | 22 ++--- CRM/Campaign/DAO/Survey.php | 37 ++------- CRM/Case/DAO/Case.php | 25 ++---- CRM/Case/DAO/CaseActivity.php | 20 ++--- CRM/Case/DAO/CaseContact.php | 20 ++--- CRM/Case/DAO/CaseType.php | 25 ++---- CRM/Contact/DAO/ACLContactCache.php | 21 ++--- CRM/Contact/DAO/Contact.php | 69 ++-------------- CRM/Contact/DAO/ContactType.php | 25 ++---- CRM/Contact/DAO/DashboardContact.php | 27 ++---- CRM/Contact/DAO/Group.php | 37 ++------- CRM/Contact/DAO/GroupContact.php | 23 ++---- CRM/Contact/DAO/GroupContactCache.php | 20 ++--- CRM/Contact/DAO/GroupNesting.php | 20 ++--- CRM/Contact/DAO/GroupOrganization.php | 20 ++--- CRM/Contact/DAO/Relationship.php | 28 ++----- CRM/Contact/DAO/RelationshipType.php | 29 ++----- CRM/Contact/DAO/SavedSearch.php | 24 ++---- CRM/Contact/DAO/SubscriptionHistory.php | 24 ++---- CRM/Contribute/DAO/Contribution.php | 46 ++--------- CRM/Contribute/DAO/ContributionPage.php | 62 ++------------ CRM/Contribute/DAO/ContributionProduct.php | 27 ++---- CRM/Contribute/DAO/ContributionRecur.php | 45 ++-------- CRM/Contribute/DAO/ContributionSoft.php | 27 ++---- CRM/Contribute/DAO/Premium.php | 28 ++----- CRM/Contribute/DAO/PremiumsProduct.php | 22 ++--- CRM/Contribute/DAO/Product.php | 36 ++------ CRM/Contribute/DAO/Widget.php | 34 ++------ CRM/Core/DAO/ActionLog.php | 27 ++---- CRM/Core/DAO/ActionMapping.php | 26 ++---- CRM/Core/DAO/ActionSchedule.php | 55 ++----------- CRM/Core/DAO/Address.php | 46 ++--------- CRM/Core/DAO/AddressFormat.php | 19 ++--- CRM/Core/DAO/AllCoreTables.data.php | 2 +- CRM/Core/DAO/Cache.php | 24 ++---- CRM/Core/DAO/Component.php | 20 ++--- CRM/Core/DAO/Country.php | 26 ++---- CRM/Core/DAO/County.php | 21 ++--- CRM/Core/DAO/CustomField.php | 47 ++--------- CRM/Core/DAO/CustomGroup.php | 37 ++------- CRM/Core/DAO/Dashboard.php | 31 ++----- CRM/Core/DAO/Discount.php | 23 ++---- CRM/Core/DAO/Domain.php | 25 ++---- CRM/Core/DAO/Email.php | 29 ++----- CRM/Core/DAO/EntityFile.php | 21 ++--- CRM/Core/DAO/EntityTag.php | 21 ++--- CRM/Core/DAO/Extension.php | 25 ++---- CRM/Core/DAO/File.php | 24 ++---- CRM/Core/DAO/IM.php | 24 ++---- CRM/Core/DAO/Job.php | 28 ++----- CRM/Core/DAO/JobLog.php | 25 ++---- CRM/Core/DAO/LocBlock.php | 26 ++---- CRM/Core/DAO/LocationType.php | 25 ++---- CRM/Core/DAO/Log.php | 23 ++---- CRM/Core/DAO/MailSettings.php | 31 ++----- CRM/Core/DAO/Managed.php | 23 ++---- CRM/Core/DAO/Mapping.php | 21 ++--- CRM/Core/DAO/MappingField.php | 31 ++----- CRM/Core/DAO/Menu.php | 38 ++------- CRM/Core/DAO/MessageTemplate.php | 28 ++----- CRM/Core/DAO/Navigation.php | 28 ++----- CRM/Core/DAO/Note.php | 25 ++---- CRM/Core/DAO/OpenID.php | 23 ++---- CRM/Core/DAO/OptionGroup.php | 24 ++---- CRM/Core/DAO/OptionValue.php | 33 ++------ CRM/Core/DAO/Persistent.php | 22 ++--- CRM/Core/DAO/Phone.php | 27 ++---- CRM/Core/DAO/PreferencesDate.php | 24 ++---- CRM/Core/DAO/PrevNextCache.php | 24 ++---- CRM/Core/DAO/PrintLabel.php | 28 ++----- CRM/Core/DAO/RecurringEntity.php | 22 ++--- CRM/Core/DAO/Setting.php | 26 ++---- CRM/Core/DAO/StateProvince.php | 21 ++--- CRM/Core/DAO/StatusPreference.php | 24 ++---- CRM/Core/DAO/SystemLog.php | 24 ++---- CRM/Core/DAO/Tag.php | 27 ++---- CRM/Core/DAO/Timezone.php | 23 ++---- CRM/Core/DAO/UFField.php | 36 ++------ CRM/Core/DAO/UFGroup.php | 40 ++------- CRM/Core/DAO/UFJoin.php | 25 ++---- CRM/Core/DAO/UFMatch.php | 23 ++---- CRM/Core/DAO/Website.php | 21 ++--- CRM/Core/DAO/WordReplacement.php | 23 ++---- CRM/Core/DAO/Worldregion.php | 19 ++--- CRM/Cxn/DAO/Cxn.php | 28 ++----- CRM/Dedupe/DAO/Exception.php | 20 ++--- CRM/Dedupe/DAO/Rule.php | 23 ++---- CRM/Dedupe/DAO/RuleGroup.php | 24 ++---- CRM/Event/Cart/DAO/Cart.php | 20 ++--- CRM/Event/Cart/DAO/EventInCart.php | 20 ++--- CRM/Event/DAO/Event.php | 86 ++------------------ CRM/Event/DAO/Participant.php | 36 ++------ CRM/Event/DAO/ParticipantPayment.php | 20 ++--- CRM/Event/DAO/ParticipantStatusType.php | 26 ++---- CRM/Financial/DAO/Currency.php | 22 ++--- CRM/Financial/DAO/EntityFinancialAccount.php | 22 ++--- CRM/Financial/DAO/EntityFinancialTrxn.php | 22 ++--- CRM/Financial/DAO/FinancialAccount.php | 34 ++------ CRM/Financial/DAO/FinancialItem.php | 28 ++----- CRM/Financial/DAO/FinancialTrxn.php | 32 ++------ CRM/Financial/DAO/FinancialType.php | 23 ++---- CRM/Financial/DAO/PaymentProcessor.php | 38 ++------- CRM/Financial/DAO/PaymentProcessorType.php | 40 ++------- CRM/Financial/DAO/PaymentToken.php | 30 ++----- CRM/Friend/DAO/Friend.php | 27 ++---- CRM/Grant/DAO/Grant.php | 32 ++------ CRM/Mailing/DAO/BouncePattern.php | 20 ++--- CRM/Mailing/DAO/BounceType.php | 21 ++--- CRM/Mailing/DAO/Component.php | 25 ++---- CRM/Mailing/DAO/Mailing.php | 56 ++----------- CRM/Mailing/DAO/MailingAB.php | 31 ++----- CRM/Mailing/DAO/MailingGroup.php | 24 ++---- CRM/Mailing/DAO/MailingJob.php | 28 ++----- CRM/Mailing/DAO/Recipients.php | 22 ++--- CRM/Mailing/DAO/Spool.php | 24 ++---- CRM/Mailing/DAO/TrackableURL.php | 20 ++--- CRM/Mailing/Event/DAO/Bounce.php | 22 ++--- CRM/Mailing/Event/DAO/Confirm.php | 20 ++--- CRM/Mailing/Event/DAO/Delivered.php | 20 ++--- CRM/Mailing/Event/DAO/Forward.php | 21 ++--- CRM/Mailing/Event/DAO/Opened.php | 20 ++--- CRM/Mailing/Event/DAO/Queue.php | 23 ++---- CRM/Mailing/Event/DAO/Reply.php | 20 ++--- CRM/Mailing/Event/DAO/Subscribe.php | 22 ++--- CRM/Mailing/Event/DAO/TrackableURLOpen.php | 21 ++--- CRM/Mailing/Event/DAO/Unsubscribe.php | 21 ++--- CRM/Member/DAO/Membership.php | 32 ++------ CRM/Member/DAO/MembershipBlock.php | 30 ++----- CRM/Member/DAO/MembershipLog.php | 26 ++---- CRM/Member/DAO/MembershipPayment.php | 20 ++--- CRM/Member/DAO/MembershipStatus.php | 32 ++------ CRM/Member/DAO/MembershipType.php | 38 ++------- CRM/PCP/DAO/PCP.php | 33 ++------ CRM/PCP/DAO/PCPBlock.php | 30 ++----- CRM/Pledge/DAO/Pledge.php | 40 ++------- CRM/Pledge/DAO/PledgeBlock.php | 28 ++----- CRM/Pledge/DAO/PledgePayment.php | 27 ++---- CRM/Price/DAO/LineItem.php | 31 ++----- CRM/Price/DAO/PriceField.php | 34 ++------ CRM/Price/DAO/PriceFieldValue.php | 34 ++------ CRM/Price/DAO/PriceSet.php | 29 ++----- CRM/Price/DAO/PriceSetEntity.php | 21 ++--- CRM/Queue/DAO/QueueItem.php | 23 ++---- CRM/Report/DAO/ReportInstance.php | 38 ++------- CRM/SMS/DAO/Provider.php | 27 ++---- 153 files changed, 761 insertions(+), 3495 deletions(-) diff --git a/CRM/ACL/DAO/ACL.php b/CRM/ACL/DAO/ACL.php index 2a2c59734c..8b07f73630 100644 --- a/CRM/ACL/DAO/ACL.php +++ b/CRM/ACL/DAO/ACL.php @@ -47,12 +47,6 @@ class CRM_ACL_DAO_ACL extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -262,28 +256,16 @@ class CRM_ACL_DAO_ACL extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'deny' => 'deny', - 'entity_table' => 'entity_table', - 'entity_id' => 'entity_id', - 'operation' => 'operation', - 'object_table' => 'object_table', - 'object_id' => 'object_id', - 'acl_table' => 'acl_table', - 'acl_id' => 'acl_id', - 'is_active' => 'is_active', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/ACL/DAO/Cache.php b/CRM/ACL/DAO/Cache.php index 2a53c38d94..6aca3cbcd5 100644 --- a/CRM/ACL/DAO/Cache.php +++ b/CRM/ACL/DAO/Cache.php @@ -47,12 +47,6 @@ class CRM_ACL_DAO_Cache extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -155,21 +149,16 @@ class CRM_ACL_DAO_Cache extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'contact_id' => 'contact_id', - 'acl_id' => 'acl_id', - 'modified_date' => 'modified_date', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/ACL/DAO/EntityRole.php b/CRM/ACL/DAO/EntityRole.php index ef9128cf02..4e245eba04 100644 --- a/CRM/ACL/DAO/EntityRole.php +++ b/CRM/ACL/DAO/EntityRole.php @@ -47,12 +47,6 @@ class CRM_ACL_DAO_EntityRole extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -167,22 +161,16 @@ class CRM_ACL_DAO_EntityRole extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'acl_role_id' => 'acl_role_id', - 'entity_table' => 'entity_table', - 'entity_id' => 'entity_id', - 'is_active' => 'is_active', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Activity/DAO/Activity.php b/CRM/Activity/DAO/Activity.php index cf4c37f011..2d5e0c232b 100644 --- a/CRM/Activity/DAO/Activity.php +++ b/CRM/Activity/DAO/Activity.php @@ -47,12 +47,6 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -546,41 +540,16 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'activity_id', - 'source_record_id' => 'source_record_id', - 'activity_type_id' => 'activity_type_id', - 'subject' => 'activity_subject', - 'activity_date_time' => 'activity_date_time', - 'duration' => 'activity_duration', - 'location' => 'activity_location', - 'phone_id' => 'phone_id', - 'phone_number' => 'phone_number', - 'details' => 'activity_details', - 'status_id' => 'activity_status_id', - 'priority_id' => 'priority_id', - 'parent_id' => 'parent_id', - 'is_test' => 'activity_is_test', - 'medium_id' => 'activity_medium_id', - 'is_auto' => 'is_auto', - 'relationship_id' => 'relationship_id', - 'is_current_revision' => 'is_current_revision', - 'original_id' => 'original_id', - 'result' => 'activity_result', - 'is_deleted' => 'activity_is_deleted', - 'campaign_id' => 'activity_campaign_id', - 'engagement_level' => 'activity_engagement_level', - 'weight' => 'weight', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Activity/DAO/ActivityContact.php b/CRM/Activity/DAO/ActivityContact.php index 26a52560ae..f6a6d38576 100644 --- a/CRM/Activity/DAO/ActivityContact.php +++ b/CRM/Activity/DAO/ActivityContact.php @@ -47,12 +47,6 @@ class CRM_Activity_DAO_ActivityContact extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -167,21 +161,16 @@ class CRM_Activity_DAO_ActivityContact extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'activity_id' => 'activity_id', - 'contact_id' => 'contact_id', - 'record_type_id' => 'record_type_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Batch/DAO/Batch.php b/CRM/Batch/DAO/Batch.php index a66df35453..ee02f29bc3 100644 --- a/CRM/Batch/DAO/Batch.php +++ b/CRM/Batch/DAO/Batch.php @@ -47,12 +47,6 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -369,34 +363,16 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'title' => 'title', - 'description' => 'description', - 'created_id' => 'created_id', - 'created_date' => 'created_date', - 'modified_id' => 'modified_id', - 'modified_date' => 'modified_date', - 'saved_search_id' => 'saved_search_id', - 'status_id' => 'status_id', - 'type_id' => 'type_id', - 'mode_id' => 'mode_id', - 'total' => 'total', - 'item_count' => 'item_count', - 'payment_instrument_id' => 'payment_instrument_id', - 'exported_date' => 'exported_date', - 'data' => 'data', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Batch/DAO/EntityBatch.php b/CRM/Batch/DAO/EntityBatch.php index ae7dde96ca..50d790e876 100644 --- a/CRM/Batch/DAO/EntityBatch.php +++ b/CRM/Batch/DAO/EntityBatch.php @@ -47,12 +47,6 @@ class CRM_Batch_DAO_EntityBatch extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -156,21 +150,16 @@ class CRM_Batch_DAO_EntityBatch extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'entity_table' => 'entity_table', - 'entity_id' => 'entity_id', - 'batch_id' => 'batch_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Campaign/DAO/Campaign.php b/CRM/Campaign/DAO/Campaign.php index bdc00d6c36..4da1996b36 100644 --- a/CRM/Campaign/DAO/Campaign.php +++ b/CRM/Campaign/DAO/Campaign.php @@ -47,12 +47,6 @@ class CRM_Campaign_DAO_Campaign extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -420,34 +414,16 @@ class CRM_Campaign_DAO_Campaign extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'title' => 'title', - 'description' => 'description', - 'start_date' => 'start_date', - 'end_date' => 'end_date', - 'campaign_type_id' => 'campaign_type_id', - 'status_id' => 'status_id', - 'external_identifier' => 'external_identifier', - 'parent_id' => 'parent_id', - 'is_active' => 'is_active', - 'created_id' => 'created_id', - 'created_date' => 'created_date', - 'last_modified_id' => 'last_modified_id', - 'last_modified_date' => 'last_modified_date', - 'goal_general' => 'goal_general', - 'goal_revenue' => 'goal_revenue', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Campaign/DAO/CampaignGroup.php b/CRM/Campaign/DAO/CampaignGroup.php index 5a50c36fed..99c9a00d52 100644 --- a/CRM/Campaign/DAO/CampaignGroup.php +++ b/CRM/Campaign/DAO/CampaignGroup.php @@ -47,12 +47,6 @@ class CRM_Campaign_DAO_CampaignGroup extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -183,22 +177,16 @@ class CRM_Campaign_DAO_CampaignGroup extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'campaign_id' => 'campaign_id', - 'group_type' => 'group_type', - 'entity_table' => 'entity_table', - 'entity_id' => 'entity_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Campaign/DAO/Survey.php b/CRM/Campaign/DAO/Survey.php index 726876fb49..45b2281e2b 100644 --- a/CRM/Campaign/DAO/Survey.php +++ b/CRM/Campaign/DAO/Survey.php @@ -47,12 +47,6 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -397,37 +391,16 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'title' => 'title', - 'campaign_id' => 'campaign_id', - 'activity_type_id' => 'activity_type_id', - 'recontact_interval' => 'recontact_interval', - 'instructions' => 'instructions', - 'release_frequency' => 'release_frequency', - 'max_number_of_contacts' => 'max_number_of_contacts', - 'default_number_of_contacts' => 'default_number_of_contacts', - 'is_active' => 'is_active', - 'is_default' => 'is_default', - 'created_id' => 'created_id', - 'created_date' => 'created_date', - 'last_modified_id' => 'last_modified_id', - 'last_modified_date' => 'last_modified_date', - 'result_id' => 'result_id', - 'bypass_confirm' => 'bypass_confirm', - 'thankyou_title' => 'thankyou_title', - 'thankyou_text' => 'thankyou_text', - 'is_share' => 'is_share', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Case/DAO/Case.php b/CRM/Case/DAO/Case.php index 8393cf2889..526965fc77 100644 --- a/CRM/Case/DAO/Case.php +++ b/CRM/Case/DAO/Case.php @@ -47,12 +47,6 @@ class CRM_Case_DAO_Case extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -264,25 +258,16 @@ class CRM_Case_DAO_Case extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'case_id', - 'case_type_id' => 'case_type_id', - 'subject' => 'case_subject', - 'start_date' => 'case_start_date', - 'end_date' => 'case_end_date', - 'details' => 'details', - 'status_id' => 'case_status_id', - 'is_deleted' => 'case_deleted', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Case/DAO/CaseActivity.php b/CRM/Case/DAO/CaseActivity.php index c6f76abbde..738e7ac7e2 100644 --- a/CRM/Case/DAO/CaseActivity.php +++ b/CRM/Case/DAO/CaseActivity.php @@ -47,12 +47,6 @@ class CRM_Case_DAO_CaseActivity extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -143,20 +137,16 @@ class CRM_Case_DAO_CaseActivity extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'case_id' => 'case_id', - 'activity_id' => 'activity_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Case/DAO/CaseContact.php b/CRM/Case/DAO/CaseContact.php index 94b57ed8c2..8143ed8ff8 100644 --- a/CRM/Case/DAO/CaseContact.php +++ b/CRM/Case/DAO/CaseContact.php @@ -47,12 +47,6 @@ class CRM_Case_DAO_CaseContact extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -146,20 +140,16 @@ class CRM_Case_DAO_CaseContact extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'case_id' => 'case_id', - 'contact_id' => 'case_contact_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Case/DAO/CaseType.php b/CRM/Case/DAO/CaseType.php index 2fc7f1132f..4c34b5a39a 100644 --- a/CRM/Case/DAO/CaseType.php +++ b/CRM/Case/DAO/CaseType.php @@ -47,12 +47,6 @@ class CRM_Case_DAO_CaseType extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -195,25 +189,16 @@ class CRM_Case_DAO_CaseType extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'title' => 'title', - 'description' => 'description', - 'is_active' => 'is_active', - 'is_reserved' => 'is_reserved', - 'weight' => 'weight', - 'definition' => 'definition', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Contact/DAO/ACLContactCache.php b/CRM/Contact/DAO/ACLContactCache.php index 04747b4f87..015b8fcc3e 100644 --- a/CRM/Contact/DAO/ACLContactCache.php +++ b/CRM/Contact/DAO/ACLContactCache.php @@ -47,12 +47,6 @@ class CRM_Contact_DAO_ACLContactCache extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -163,21 +157,16 @@ class CRM_Contact_DAO_ACLContactCache extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'user_id' => 'user_id', - 'contact_id' => 'contact_id', - 'operation' => 'operation', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Contact/DAO/Contact.php b/CRM/Contact/DAO/Contact.php index 28e05c3cae..8c7e8a5600 100644 --- a/CRM/Contact/DAO/Contact.php +++ b/CRM/Contact/DAO/Contact.php @@ -47,12 +47,6 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -1168,69 +1162,16 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'contact_type' => 'contact_type', - 'contact_sub_type' => 'contact_sub_type', - 'do_not_email' => 'do_not_email', - 'do_not_phone' => 'do_not_phone', - 'do_not_mail' => 'do_not_mail', - 'do_not_sms' => 'do_not_sms', - 'do_not_trade' => 'do_not_trade', - 'is_opt_out' => 'is_opt_out', - 'legal_identifier' => 'legal_identifier', - 'external_identifier' => 'external_identifier', - 'sort_name' => 'sort_name', - 'display_name' => 'display_name', - 'nick_name' => 'nick_name', - 'legal_name' => 'legal_name', - 'image_URL' => 'image_URL', - 'preferred_communication_method' => 'preferred_communication_method', - 'preferred_language' => 'preferred_language', - 'preferred_mail_format' => 'preferred_mail_format', - 'hash' => 'hash', - 'api_key' => 'api_key', - 'source' => 'contact_source', - 'first_name' => 'first_name', - 'middle_name' => 'middle_name', - 'last_name' => 'last_name', - 'prefix_id' => 'prefix_id', - 'suffix_id' => 'suffix_id', - 'formal_title' => 'formal_title', - 'communication_style_id' => 'communication_style_id', - 'email_greeting_id' => 'email_greeting_id', - 'email_greeting_custom' => 'email_greeting_custom', - 'email_greeting_display' => 'email_greeting_display', - 'postal_greeting_id' => 'postal_greeting_id', - 'postal_greeting_custom' => 'postal_greeting_custom', - 'postal_greeting_display' => 'postal_greeting_display', - 'addressee_id' => 'addressee_id', - 'addressee_custom' => 'addressee_custom', - 'addressee_display' => 'addressee_display', - 'job_title' => 'job_title', - 'gender_id' => 'gender_id', - 'birth_date' => 'birth_date', - 'is_deceased' => 'is_deceased', - 'deceased_date' => 'deceased_date', - 'household_name' => 'household_name', - 'primary_contact_id' => 'primary_contact_id', - 'organization_name' => 'organization_name', - 'sic_code' => 'sic_code', - 'user_unique_id' => 'user_unique_id', - 'employer_id' => 'current_employer_id', - 'is_deleted' => 'contact_is_deleted', - 'created_date' => 'created_date', - 'modified_date' => 'modified_date', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Contact/DAO/ContactType.php b/CRM/Contact/DAO/ContactType.php index 1ea5ac24e1..b7d008d3f9 100644 --- a/CRM/Contact/DAO/ContactType.php +++ b/CRM/Contact/DAO/ContactType.php @@ -47,12 +47,6 @@ class CRM_Contact_DAO_ContactType extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -216,25 +210,16 @@ class CRM_Contact_DAO_ContactType extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'label' => 'label', - 'description' => 'description', - 'image_URL' => 'image_URL', - 'parent_id' => 'parent_id', - 'is_active' => 'is_active', - 'is_reserved' => 'is_reserved', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Contact/DAO/DashboardContact.php b/CRM/Contact/DAO/DashboardContact.php index e44239f3e9..4e780cdefe 100644 --- a/CRM/Contact/DAO/DashboardContact.php +++ b/CRM/Contact/DAO/DashboardContact.php @@ -47,12 +47,6 @@ class CRM_Contact_DAO_DashboardContact extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -226,27 +220,16 @@ class CRM_Contact_DAO_DashboardContact extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'dashboard_id' => 'dashboard_id', - 'contact_id' => 'contact_id', - 'column_no' => 'column_no', - 'is_minimized' => 'is_minimized', - 'is_fullscreen' => 'is_fullscreen', - 'is_active' => 'is_active', - 'weight' => 'weight', - 'content' => 'content', - 'created_date' => 'created_date', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Contact/DAO/Group.php b/CRM/Contact/DAO/Group.php index e60d70df2c..bc9444453c 100644 --- a/CRM/Contact/DAO/Group.php +++ b/CRM/Contact/DAO/Group.php @@ -47,12 +47,6 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -373,37 +367,16 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'title' => 'title', - 'description' => 'description', - 'source' => 'source', - 'saved_search_id' => 'saved_search_id', - 'is_active' => 'is_active', - 'visibility' => 'visibility', - 'where_clause' => 'where_clause', - 'select_tables' => 'select_tables', - 'where_tables' => 'where_tables', - 'group_type' => 'group_type', - 'cache_date' => 'cache_date', - 'refresh_date' => 'refresh_date', - 'parents' => 'parents', - 'children' => 'children', - 'is_hidden' => 'is_hidden', - 'is_reserved' => 'is_reserved', - 'created_id' => 'created_id', - 'modified_id' => 'modified_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Contact/DAO/GroupContact.php b/CRM/Contact/DAO/GroupContact.php index d649e281e7..87c3e48bc7 100644 --- a/CRM/Contact/DAO/GroupContact.php +++ b/CRM/Contact/DAO/GroupContact.php @@ -47,12 +47,6 @@ class CRM_Contact_DAO_GroupContact extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -199,23 +193,16 @@ class CRM_Contact_DAO_GroupContact extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'group_id' => 'group_id', - 'contact_id' => 'contact_id', - 'status' => 'status', - 'location_id' => 'location_id', - 'email_id' => 'email_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Contact/DAO/GroupContactCache.php b/CRM/Contact/DAO/GroupContactCache.php index c470ecfff7..6924273f57 100644 --- a/CRM/Contact/DAO/GroupContactCache.php +++ b/CRM/Contact/DAO/GroupContactCache.php @@ -47,12 +47,6 @@ class CRM_Contact_DAO_GroupContactCache extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -151,20 +145,16 @@ class CRM_Contact_DAO_GroupContactCache extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'group_id' => 'group_id', - 'contact_id' => 'contact_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Contact/DAO/GroupNesting.php b/CRM/Contact/DAO/GroupNesting.php index 1e7caf732b..79a3b87232 100644 --- a/CRM/Contact/DAO/GroupNesting.php +++ b/CRM/Contact/DAO/GroupNesting.php @@ -47,12 +47,6 @@ class CRM_Contact_DAO_GroupNesting extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -143,20 +137,16 @@ class CRM_Contact_DAO_GroupNesting extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'child_group_id' => 'child_group_id', - 'parent_group_id' => 'parent_group_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Contact/DAO/GroupOrganization.php b/CRM/Contact/DAO/GroupOrganization.php index ff90ad0884..93ba27fc24 100644 --- a/CRM/Contact/DAO/GroupOrganization.php +++ b/CRM/Contact/DAO/GroupOrganization.php @@ -47,12 +47,6 @@ class CRM_Contact_DAO_GroupOrganization extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -151,20 +145,16 @@ class CRM_Contact_DAO_GroupOrganization extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'group_id' => 'group_id', - 'organization_id' => 'organization_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Contact/DAO/Relationship.php b/CRM/Contact/DAO/Relationship.php index a505bacafe..b6ded4a951 100644 --- a/CRM/Contact/DAO/Relationship.php +++ b/CRM/Contact/DAO/Relationship.php @@ -47,12 +47,6 @@ class CRM_Contact_DAO_Relationship extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -278,28 +272,16 @@ class CRM_Contact_DAO_Relationship extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'contact_id_a' => 'contact_id_a', - 'contact_id_b' => 'contact_id_b', - 'relationship_type_id' => 'relationship_type_id', - 'start_date' => 'start_date', - 'end_date' => 'end_date', - 'is_active' => 'is_active', - 'description' => 'description', - 'is_permission_a_b' => 'is_permission_a_b', - 'is_permission_b_a' => 'is_permission_b_a', - 'case_id' => 'case_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Contact/DAO/RelationshipType.php b/CRM/Contact/DAO/RelationshipType.php index edb7bbd58a..e2c020657a 100644 --- a/CRM/Contact/DAO/RelationshipType.php +++ b/CRM/Contact/DAO/RelationshipType.php @@ -47,12 +47,6 @@ class CRM_Contact_DAO_RelationshipType extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -291,29 +285,16 @@ class CRM_Contact_DAO_RelationshipType extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name_a_b' => 'name_a_b', - 'label_a_b' => 'label_a_b', - 'name_b_a' => 'name_b_a', - 'label_b_a' => 'label_b_a', - 'description' => 'description', - 'contact_type_a' => 'contact_type_a', - 'contact_type_b' => 'contact_type_b', - 'contact_sub_type_a' => 'contact_sub_type_a', - 'contact_sub_type_b' => 'contact_sub_type_b', - 'is_reserved' => 'is_reserved', - 'is_active' => 'is_active', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Contact/DAO/SavedSearch.php b/CRM/Contact/DAO/SavedSearch.php index a3afb89f86..f605edbbba 100644 --- a/CRM/Contact/DAO/SavedSearch.php +++ b/CRM/Contact/DAO/SavedSearch.php @@ -47,12 +47,6 @@ class CRM_Contact_DAO_SavedSearch extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -192,24 +186,16 @@ class CRM_Contact_DAO_SavedSearch extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'form_values' => 'form_values', - 'mapping_id' => 'mapping_id', - 'search_custom_id' => 'search_custom_id', - 'where_clause' => 'where_clause', - 'select_tables' => 'select_tables', - 'where_tables' => 'where_tables', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Contact/DAO/SubscriptionHistory.php b/CRM/Contact/DAO/SubscriptionHistory.php index cb855e99a5..b21fed5a4e 100644 --- a/CRM/Contact/DAO/SubscriptionHistory.php +++ b/CRM/Contact/DAO/SubscriptionHistory.php @@ -47,12 +47,6 @@ class CRM_Contact_DAO_SubscriptionHistory extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -214,24 +208,16 @@ class CRM_Contact_DAO_SubscriptionHistory extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'contact_id' => 'contact_id', - 'group_id' => 'group_id', - 'date' => 'date', - 'method' => 'method', - 'status' => 'status', - 'tracking' => 'tracking', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Contribute/DAO/Contribution.php b/CRM/Contribute/DAO/Contribution.php index e2cf91592c..7c7180153a 100644 --- a/CRM/Contribute/DAO/Contribution.php +++ b/CRM/Contribute/DAO/Contribution.php @@ -47,12 +47,6 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -721,46 +715,16 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'contribution_id', - 'contact_id' => 'contribution_contact_id', - 'financial_type_id' => 'financial_type_id', - 'contribution_page_id' => 'contribution_page_id', - 'payment_instrument_id' => 'payment_instrument_id', - 'receive_date' => 'receive_date', - 'non_deductible_amount' => 'non_deductible_amount', - 'total_amount' => 'total_amount', - 'fee_amount' => 'fee_amount', - 'net_amount' => 'net_amount', - 'trxn_id' => 'trxn_id', - 'invoice_id' => 'invoice_id', - 'currency' => 'currency', - 'cancel_date' => 'cancel_date', - 'cancel_reason' => 'cancel_reason', - 'receipt_date' => 'receipt_date', - 'thankyou_date' => 'thankyou_date', - 'source' => 'contribution_source', - 'amount_level' => 'amount_level', - 'contribution_recur_id' => 'contribution_recur_id', - 'is_test' => 'is_test', - 'is_pay_later' => 'is_pay_later', - 'contribution_status_id' => 'contribution_status_id', - 'address_id' => 'address_id', - 'check_number' => 'check_number', - 'campaign_id' => 'contribution_campaign_id', - 'creditnote_id' => 'creditnote_id', - 'tax_amount' => 'tax_amount', - 'revenue_recognition_date' => 'revenue_recognition_date', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Contribute/DAO/ContributionPage.php b/CRM/Contribute/DAO/ContributionPage.php index 8598b1dfdd..91caac058d 100644 --- a/CRM/Contribute/DAO/ContributionPage.php +++ b/CRM/Contribute/DAO/ContributionPage.php @@ -47,12 +47,6 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -743,62 +737,16 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'title' => 'title', - 'intro_text' => 'intro_text', - 'financial_type_id' => 'financial_type_id', - 'payment_processor' => 'payment_processor', - 'is_credit_card_only' => 'is_credit_card_only', - 'is_monetary' => 'is_monetary', - 'is_recur' => 'is_recur', - 'is_confirm_enabled' => 'is_confirm_enabled', - 'recur_frequency_unit' => 'recur_frequency_unit', - 'is_recur_interval' => 'is_recur_interval', - 'is_recur_installments' => 'is_recur_installments', - 'adjust_recur_start_date' => 'adjust_recur_start_date', - 'is_pay_later' => 'is_pay_later', - 'pay_later_text' => 'pay_later_text', - 'pay_later_receipt' => 'pay_later_receipt', - 'is_partial_payment' => 'is_partial_payment', - 'initial_amount_label' => 'initial_amount_label', - 'initial_amount_help_text' => 'initial_amount_help_text', - 'min_initial_amount' => 'min_initial_amount', - 'is_allow_other_amount' => 'is_allow_other_amount', - 'default_amount_id' => 'default_amount_id', - 'min_amount' => 'min_amount', - 'max_amount' => 'max_amount', - 'goal_amount' => 'goal_amount', - 'thankyou_title' => 'thankyou_title', - 'thankyou_text' => 'thankyou_text', - 'thankyou_footer' => 'thankyou_footer', - 'is_email_receipt' => 'is_email_receipt', - 'receipt_from_name' => 'receipt_from_name', - 'receipt_from_email' => 'receipt_from_email', - 'cc_receipt' => 'cc_receipt', - 'bcc_receipt' => 'bcc_receipt', - 'receipt_text' => 'receipt_text', - 'is_active' => 'is_active', - 'footer_text' => 'footer_text', - 'amount_block_is_active' => 'amount_block_is_active', - 'start_date' => 'start_date', - 'end_date' => 'end_date', - 'created_id' => 'created_id', - 'created_date' => 'created_date', - 'currency' => 'currency', - 'campaign_id' => 'campaign_id', - 'is_share' => 'is_share', - 'is_billing_required' => 'is_billing_required', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Contribute/DAO/ContributionProduct.php b/CRM/Contribute/DAO/ContributionProduct.php index 2ceea9354e..b22c8d84e0 100644 --- a/CRM/Contribute/DAO/ContributionProduct.php +++ b/CRM/Contribute/DAO/ContributionProduct.php @@ -47,12 +47,6 @@ class CRM_Contribute_DAO_ContributionProduct extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -245,27 +239,16 @@ class CRM_Contribute_DAO_ContributionProduct extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'product_id' => 'product_id', - 'contribution_id' => 'contribution_id', - 'product_option' => 'product_option', - 'quantity' => 'quantity', - 'fulfilled_date' => 'fulfilled_date', - 'start_date' => 'contribution_start_date', - 'end_date' => 'contribution_end_date', - 'comment' => 'comment', - 'financial_type_id' => 'financial_type_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Contribute/DAO/ContributionRecur.php b/CRM/Contribute/DAO/ContributionRecur.php index 293fc03ddd..3b5d13adbe 100644 --- a/CRM/Contribute/DAO/ContributionRecur.php +++ b/CRM/Contribute/DAO/ContributionRecur.php @@ -47,12 +47,6 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -571,45 +565,16 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'contact_id' => 'contact_id', - 'amount' => 'amount', - 'currency' => 'currency', - 'frequency_unit' => 'frequency_unit', - 'frequency_interval' => 'frequency_interval', - 'installments' => 'installments', - 'start_date' => 'start_date', - 'create_date' => 'create_date', - 'modified_date' => 'modified_date', - 'cancel_date' => 'cancel_date', - 'end_date' => 'end_date', - 'processor_id' => 'processor_id', - 'payment_token_id' => 'payment_token_id', - 'trxn_id' => 'trxn_id', - 'invoice_id' => 'invoice_id', - 'contribution_status_id' => 'contribution_status_id', - 'is_test' => 'is_test', - 'cycle_day' => 'cycle_day', - 'next_sched_contribution_date' => 'next_sched_contribution_date', - 'failure_count' => 'failure_count', - 'failure_retry_date' => 'failure_retry_date', - 'auto_renew' => 'auto_renew', - 'payment_processor_id' => 'payment_processor_id', - 'financial_type_id' => 'financial_type_id', - 'payment_instrument_id' => 'payment_instrument_id', - 'campaign_id' => 'contribution_campaign_id', - 'is_email_receipt' => 'is_email_receipt', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Contribute/DAO/ContributionSoft.php b/CRM/Contribute/DAO/ContributionSoft.php index 15210db9a5..bef532262f 100644 --- a/CRM/Contribute/DAO/ContributionSoft.php +++ b/CRM/Contribute/DAO/ContributionSoft.php @@ -47,12 +47,6 @@ class CRM_Contribute_DAO_ContributionSoft extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -272,27 +266,16 @@ class CRM_Contribute_DAO_ContributionSoft extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'contribution_soft_id', - 'contribution_id' => 'contribution_id', - 'contact_id' => 'contribution_soft_contact_id', - 'amount' => 'amount', - 'currency' => 'currency', - 'pcp_id' => 'pcp_id', - 'pcp_display_in_roll' => 'pcp_display_in_roll', - 'pcp_roll_nickname' => 'pcp_roll_nickname', - 'pcp_personal_note' => 'pcp_personal_note', - 'soft_credit_type_id' => 'soft_credit_type_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Contribute/DAO/Premium.php b/CRM/Contribute/DAO/Premium.php index 0d8e84f7f5..fd28e77e47 100644 --- a/CRM/Contribute/DAO/Premium.php +++ b/CRM/Contribute/DAO/Premium.php @@ -47,12 +47,6 @@ class CRM_Contribute_DAO_Premium extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -243,28 +237,16 @@ class CRM_Contribute_DAO_Premium extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'entity_table' => 'entity_table', - 'entity_id' => 'entity_id', - 'premiums_active' => 'premiums_active', - 'premiums_intro_title' => 'premiums_intro_title', - 'premiums_intro_text' => 'premiums_intro_text', - 'premiums_contact_email' => 'premiums_contact_email', - 'premiums_contact_phone' => 'premiums_contact_phone', - 'premiums_display_min_contribution' => 'premiums_display_min_contribution', - 'premiums_nothankyou_label' => 'premiums_nothankyou_label', - 'premiums_nothankyou_position' => 'premiums_nothankyou_position', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Contribute/DAO/PremiumsProduct.php b/CRM/Contribute/DAO/PremiumsProduct.php index 39592b84c0..7bbae64b83 100644 --- a/CRM/Contribute/DAO/PremiumsProduct.php +++ b/CRM/Contribute/DAO/PremiumsProduct.php @@ -47,12 +47,6 @@ class CRM_Contribute_DAO_PremiumsProduct extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -174,22 +168,16 @@ class CRM_Contribute_DAO_PremiumsProduct extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'premiums_id' => 'premiums_id', - 'product_id' => 'product_id', - 'weight' => 'weight', - 'financial_type_id' => 'financial_type_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Contribute/DAO/Product.php b/CRM/Contribute/DAO/Product.php index 79ab2fd31e..ad79ad1d27 100644 --- a/CRM/Contribute/DAO/Product.php +++ b/CRM/Contribute/DAO/Product.php @@ -47,12 +47,6 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -405,36 +399,16 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'product_name', - 'description' => 'description', - 'sku' => 'sku', - 'options' => 'options', - 'image' => 'image', - 'thumbnail' => 'thumbnail', - 'price' => 'price', - 'currency' => 'currency', - 'financial_type_id' => 'financial_type_id', - 'min_contribution' => 'min_contribution', - 'cost' => 'cost', - 'is_active' => 'is_active', - 'period_type' => 'period_type', - 'fixed_period_start_day' => 'fixed_period_start_day', - 'duration_unit' => 'duration_unit', - 'duration_interval' => 'duration_interval', - 'frequency_unit' => 'frequency_unit', - 'frequency_interval' => 'frequency_interval', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Contribute/DAO/Widget.php b/CRM/Contribute/DAO/Widget.php index d6b3ebbfb2..4d533ef440 100644 --- a/CRM/Contribute/DAO/Widget.php +++ b/CRM/Contribute/DAO/Widget.php @@ -47,12 +47,6 @@ class CRM_Contribute_DAO_Widget extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -315,34 +309,16 @@ class CRM_Contribute_DAO_Widget extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'contribution_page_id' => 'contribution_page_id', - 'is_active' => 'is_active', - 'title' => 'title', - 'url_logo' => 'url_logo', - 'button_title' => 'button_title', - 'about' => 'about', - 'url_homepage' => 'url_homepage', - 'color_title' => 'color_title', - 'color_button' => 'color_button', - 'color_bar' => 'color_bar', - 'color_main_text' => 'color_main_text', - 'color_main' => 'color_main', - 'color_main_bg' => 'color_main_bg', - 'color_bg' => 'color_bg', - 'color_about_link' => 'color_about_link', - 'color_homepage_link' => 'color_homepage_link', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/ActionLog.php b/CRM/Core/DAO/ActionLog.php index 8cae35ed51..a5746f69fa 100644 --- a/CRM/Core/DAO/ActionLog.php +++ b/CRM/Core/DAO/ActionLog.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_ActionLog extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -229,27 +223,16 @@ class CRM_Core_DAO_ActionLog extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'contact_id' => 'contact_id', - 'entity_id' => 'entity_id', - 'entity_table' => 'entity_table', - 'action_schedule_id' => 'action_schedule_id', - 'action_date_time' => 'action_date_time', - 'is_error' => 'is_error', - 'message' => 'message', - 'repetition_number' => 'repetition_number', - 'reference_date' => 'reference_date', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/ActionMapping.php b/CRM/Core/DAO/ActionMapping.php index 66e3713f67..46959a322e 100644 --- a/CRM/Core/DAO/ActionMapping.php +++ b/CRM/Core/DAO/ActionMapping.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_ActionMapping extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -211,26 +205,16 @@ class CRM_Core_DAO_ActionMapping extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'entity' => 'entity', - 'entity_value' => 'entity_value', - 'entity_value_label' => 'entity_value_label', - 'entity_status' => 'entity_status', - 'entity_status_label' => 'entity_status_label', - 'entity_date_start' => 'entity_date_start', - 'entity_date_end' => 'entity_date_end', - 'entity_recipient' => 'entity_recipient', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/ActionSchedule.php b/CRM/Core/DAO/ActionSchedule.php index cd0a9fb401..53d56904bc 100644 --- a/CRM/Core/DAO/ActionSchedule.php +++ b/CRM/Core/DAO/ActionSchedule.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -642,55 +636,16 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'title' => 'title', - 'recipient' => 'recipient', - 'limit_to' => 'limit_to', - 'entity_value' => 'entity_value', - 'entity_status' => 'entity_status', - 'start_action_offset' => 'start_action_offset', - 'start_action_unit' => 'start_action_unit', - 'start_action_condition' => 'start_action_condition', - 'start_action_date' => 'start_action_date', - 'is_repeat' => 'is_repeat', - 'repetition_frequency_unit' => 'repetition_frequency_unit', - 'repetition_frequency_interval' => 'repetition_frequency_interval', - 'end_frequency_unit' => 'end_frequency_unit', - 'end_frequency_interval' => 'end_frequency_interval', - 'end_action' => 'end_action', - 'end_date' => 'end_date', - 'is_active' => 'is_active', - 'recipient_manual' => 'recipient_manual', - 'recipient_listing' => 'recipient_listing', - 'body_text' => 'body_text', - 'body_html' => 'body_html', - 'sms_body_text' => 'sms_body_text', - 'subject' => 'subject', - 'record_activity' => 'record_activity', - 'mapping_id' => 'mapping_id', - 'group_id' => 'group_id', - 'msg_template_id' => 'msg_template_id', - 'sms_template_id' => 'sms_template_id', - 'absolute_date' => 'absolute_date', - 'from_name' => 'from_name', - 'from_email' => 'from_email', - 'mode' => 'mode', - 'sms_provider_id' => 'sms_provider_id', - 'used_for' => 'used_for', - 'filter_contact_language' => 'filter_contact_language', - 'communication_language' => 'communication_language', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/Address.php b/CRM/Core/DAO/Address.php index 680c482210..d22e5d745c 100644 --- a/CRM/Core/DAO/Address.php +++ b/CRM/Core/DAO/Address.php @@ -50,12 +50,6 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -660,46 +654,16 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'contact_id' => 'contact_id', - 'location_type_id' => 'location_type_id', - 'is_primary' => 'is_primary', - 'is_billing' => 'is_billing', - 'street_address' => 'street_address', - 'street_number' => 'street_number', - 'street_number_suffix' => 'street_number_suffix', - 'street_number_predirectional' => 'street_number_predirectional', - 'street_name' => 'street_name', - 'street_type' => 'street_type', - 'street_number_postdirectional' => 'street_number_postdirectional', - 'street_unit' => 'street_unit', - 'supplemental_address_1' => 'supplemental_address_1', - 'supplemental_address_2' => 'supplemental_address_2', - 'supplemental_address_3' => 'supplemental_address_3', - 'city' => 'city', - 'county_id' => 'county_id', - 'state_province_id' => 'state_province_id', - 'postal_code_suffix' => 'postal_code_suffix', - 'postal_code' => 'postal_code', - 'usps_adc' => 'usps_adc', - 'country_id' => 'country_id', - 'geo_code_1' => 'geo_code_1', - 'geo_code_2' => 'geo_code_2', - 'manual_geo_code' => 'manual_geo_code', - 'timezone' => 'timezone', - 'name' => 'address_name', - 'master_id' => 'master_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/AddressFormat.php b/CRM/Core/DAO/AddressFormat.php index 7a494b0544..4da6c20e0a 100644 --- a/CRM/Core/DAO/AddressFormat.php +++ b/CRM/Core/DAO/AddressFormat.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_AddressFormat extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -113,19 +107,16 @@ class CRM_Core_DAO_AddressFormat extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'format' => 'format', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/AllCoreTables.data.php b/CRM/Core/DAO/AllCoreTables.data.php index 9aedc1fe82..3315319945 100644 --- a/CRM/Core/DAO/AllCoreTables.data.php +++ b/CRM/Core/DAO/AllCoreTables.data.php @@ -24,7 +24,7 @@ | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ */ -// (GenCodeChecksum:14fe20bf74c92c5422f20d8b99684a5b) +// (GenCodeChecksum:b13780d76d6f597c98c782343c2e5876) return array( 'CRM_Core_DAO_AddressFormat' => array( 'name' => 'AddressFormat', diff --git a/CRM/Core/DAO/Cache.php b/CRM/Core/DAO/Cache.php index 1fcee8c630..946969d3f0 100644 --- a/CRM/Core/DAO/Cache.php +++ b/CRM/Core/DAO/Cache.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_Cache extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -196,24 +190,16 @@ class CRM_Core_DAO_Cache extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'group_name' => 'group_name', - 'path' => 'path', - 'data' => 'data', - 'component_id' => 'component_id', - 'created_date' => 'created_date', - 'expired_date' => 'expired_date', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/Component.php b/CRM/Core/DAO/Component.php index d86dd2822f..93d18fa899 100644 --- a/CRM/Core/DAO/Component.php +++ b/CRM/Core/DAO/Component.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_Component extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -132,20 +126,16 @@ class CRM_Core_DAO_Component extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'namespace' => 'namespace', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/Country.php b/CRM/Core/DAO/Country.php index c72e479278..c8a9dd74d6 100644 --- a/CRM/Core/DAO/Country.php +++ b/CRM/Core/DAO/Country.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_Country extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -229,26 +223,16 @@ class CRM_Core_DAO_Country extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'iso_code' => 'iso_code', - 'country_code' => 'country_code', - 'address_format_id' => 'address_format_id', - 'idd_prefix' => 'idd_prefix', - 'ndd_prefix' => 'ndd_prefix', - 'region_id' => 'region_id', - 'is_province_abbreviated' => 'is_province_abbreviated', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/County.php b/CRM/Core/DAO/County.php index 2a6eda2f5c..720da3e04a 100644 --- a/CRM/Core/DAO/County.php +++ b/CRM/Core/DAO/County.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_County extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -161,21 +155,16 @@ class CRM_Core_DAO_County extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'abbreviation' => 'abbreviation', - 'state_province_id' => 'state_province_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/CustomField.php b/CRM/Core/DAO/CustomField.php index 2e2f321487..23a0c47ec6 100644 --- a/CRM/Core/DAO/CustomField.php +++ b/CRM/Core/DAO/CustomField.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -508,47 +502,16 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'custom_group_id' => 'custom_group_id', - 'name' => 'name', - 'label' => 'label', - 'data_type' => 'data_type', - 'html_type' => 'html_type', - 'default_value' => 'default_value', - 'is_required' => 'is_required', - 'is_searchable' => 'is_searchable', - 'is_search_range' => 'is_search_range', - 'weight' => 'weight', - 'help_pre' => 'help_pre', - 'help_post' => 'help_post', - 'mask' => 'mask', - 'attributes' => 'attributes', - 'javascript' => 'javascript', - 'is_active' => 'is_active', - 'is_view' => 'is_view', - 'options_per_line' => 'options_per_line', - 'text_length' => 'text_length', - 'start_date_years' => 'start_date_years', - 'end_date_years' => 'end_date_years', - 'date_format' => 'date_format', - 'time_format' => 'time_format', - 'note_columns' => 'note_columns', - 'note_rows' => 'note_rows', - 'column_name' => 'column_name', - 'option_group_id' => 'option_group_id', - 'filter' => 'filter', - 'in_selector' => 'in_selector', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/CustomGroup.php b/CRM/Core/DAO/CustomGroup.php index ef89ee97bc..085061e0c5 100644 --- a/CRM/Core/DAO/CustomGroup.php +++ b/CRM/Core/DAO/CustomGroup.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -376,37 +370,16 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'title' => 'title', - 'extends' => 'extends', - 'extends_entity_column_id' => 'extends_entity_column_id', - 'extends_entity_column_value' => 'extends_entity_column_value', - 'style' => 'style', - 'collapse_display' => 'collapse_display', - 'help_pre' => 'help_pre', - 'help_post' => 'help_post', - 'weight' => 'weight', - 'is_active' => 'is_active', - 'table_name' => 'table_name', - 'is_multiple' => 'is_multiple', - 'min_multiple' => 'min_multiple', - 'max_multiple' => 'max_multiple', - 'collapse_adv_display' => 'collapse_adv_display', - 'created_id' => 'created_id', - 'created_date' => 'created_date', - 'is_reserved' => 'is_reserved', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/Dashboard.php b/CRM/Core/DAO/Dashboard.php index 14f346e495..b4f4bf0fab 100644 --- a/CRM/Core/DAO/Dashboard.php +++ b/CRM/Core/DAO/Dashboard.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_Dashboard extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -288,31 +282,16 @@ class CRM_Core_DAO_Dashboard extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'domain_id' => 'domain_id', - 'name' => 'name', - 'label' => 'label', - 'url' => 'url', - 'permission' => 'permission', - 'permission_operator' => 'permission_operator', - 'column_no' => 'column_no', - 'is_minimized' => 'is_minimized', - 'fullscreen_url' => 'fullscreen_url', - 'is_fullscreen' => 'is_fullscreen', - 'is_active' => 'is_active', - 'is_reserved' => 'is_reserved', - 'weight' => 'weight', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/Discount.php b/CRM/Core/DAO/Discount.php index 51b11ab746..2e7da7c96b 100644 --- a/CRM/Core/DAO/Discount.php +++ b/CRM/Core/DAO/Discount.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_Discount extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -184,23 +178,16 @@ class CRM_Core_DAO_Discount extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'entity_table' => 'entity_table', - 'entity_id' => 'entity_id', - 'price_set_id' => 'participant_discount_name', - 'start_date' => 'start_date', - 'end_date' => 'end_date', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/Domain.php b/CRM/Core/DAO/Domain.php index a7e818375e..db7bd223ae 100644 --- a/CRM/Core/DAO/Domain.php +++ b/CRM/Core/DAO/Domain.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_Domain extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -221,25 +215,16 @@ class CRM_Core_DAO_Domain extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'description' => 'description', - 'config_backend' => 'config_backend', - 'version' => 'version', - 'contact_id' => 'contact_id', - 'locales' => 'locales', - 'locale_custom_strings' => 'locale_custom_strings', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/Email.php b/CRM/Core/DAO/Email.php index 825b7abd15..dc4022a16b 100644 --- a/CRM/Core/DAO/Email.php +++ b/CRM/Core/DAO/Email.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_Email extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -291,29 +285,16 @@ class CRM_Core_DAO_Email extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'contact_id' => 'contact_id', - 'location_type_id' => 'location_type_id', - 'email' => 'email', - 'is_primary' => 'is_primary', - 'is_billing' => 'is_billing', - 'on_hold' => 'on_hold', - 'is_bulkmail' => 'is_bulkmail', - 'hold_date' => 'hold_date', - 'reset_date' => 'reset_date', - 'signature_text' => 'signature_text', - 'signature_html' => 'signature_html', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/EntityFile.php b/CRM/Core/DAO/EntityFile.php index be13d47378..f363556322 100644 --- a/CRM/Core/DAO/EntityFile.php +++ b/CRM/Core/DAO/EntityFile.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_EntityFile extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -156,21 +150,16 @@ class CRM_Core_DAO_EntityFile extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'entity_table' => 'entity_table', - 'entity_id' => 'entity_id', - 'file_id' => 'file_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/EntityTag.php b/CRM/Core/DAO/EntityTag.php index a248eef79a..b3fcd469ee 100644 --- a/CRM/Core/DAO/EntityTag.php +++ b/CRM/Core/DAO/EntityTag.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_EntityTag extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -168,21 +162,16 @@ class CRM_Core_DAO_EntityTag extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'entity_table' => 'entity_table', - 'entity_id' => 'entity_id', - 'tag_id' => 'tag_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/Extension.php b/CRM/Core/DAO/Extension.php index 16717ae871..4eed598db3 100644 --- a/CRM/Core/DAO/Extension.php +++ b/CRM/Core/DAO/Extension.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_Extension extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -224,25 +218,16 @@ class CRM_Core_DAO_Extension extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'type' => 'type', - 'full_name' => 'full_name', - 'name' => 'name', - 'label' => 'label', - 'file' => 'file', - 'schema_version' => 'schema_version', - 'is_active' => 'is_active', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/File.php b/CRM/Core/DAO/File.php index 7216ac16f5..037ec99e9e 100644 --- a/CRM/Core/DAO/File.php +++ b/CRM/Core/DAO/File.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_File extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -179,24 +173,16 @@ class CRM_Core_DAO_File extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'file_type_id' => 'file_type_id', - 'mime_type' => 'mime_type', - 'uri' => 'uri', - 'document' => 'document', - 'description' => 'description', - 'upload_date' => 'upload_date', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/IM.php b/CRM/Core/DAO/IM.php index 08e2f2b4f0..9279c6b62d 100644 --- a/CRM/Core/DAO/IM.php +++ b/CRM/Core/DAO/IM.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_IM extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -212,24 +206,16 @@ class CRM_Core_DAO_IM extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'contact_id' => 'contact_id', - 'location_type_id' => 'location_type_id', - 'name' => 'name', - 'provider_id' => 'provider_id', - 'is_primary' => 'is_primary', - 'is_billing' => 'is_billing', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/Job.php b/CRM/Core/DAO/Job.php index 121a856a9b..6cf43c1af6 100644 --- a/CRM/Core/DAO/Job.php +++ b/CRM/Core/DAO/Job.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_Job extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -266,28 +260,16 @@ class CRM_Core_DAO_Job extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'domain_id' => 'domain_id', - 'run_frequency' => 'run_frequency', - 'last_run' => 'last_run', - 'scheduled_run_date' => 'scheduled_run_date', - 'name' => 'name', - 'description' => 'description', - 'api_entity' => 'api_entity', - 'api_action' => 'api_action', - 'parameters' => 'parameters', - 'is_active' => 'is_active', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/JobLog.php b/CRM/Core/DAO/JobLog.php index 5e22a8f562..8dcdec19a5 100644 --- a/CRM/Core/DAO/JobLog.php +++ b/CRM/Core/DAO/JobLog.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_JobLog extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -211,25 +205,16 @@ class CRM_Core_DAO_JobLog extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'domain_id' => 'domain_id', - 'run_time' => 'run_time', - 'job_id' => 'job_id', - 'name' => 'name', - 'command' => 'command', - 'description' => 'description', - 'data' => 'data', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/LocBlock.php b/CRM/Core/DAO/LocBlock.php index 658725471c..f3800a8abd 100644 --- a/CRM/Core/DAO/LocBlock.php +++ b/CRM/Core/DAO/LocBlock.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_LocBlock extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -209,26 +203,16 @@ class CRM_Core_DAO_LocBlock extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'address_id' => 'address_id', - 'email_id' => 'email_id', - 'phone_id' => 'phone_id', - 'im_id' => 'im_id', - 'address_2_id' => 'address_2_id', - 'email_2_id' => 'email_2_id', - 'phone_2_id' => 'phone_2_id', - 'im_2_id' => 'im_2_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/LocationType.php b/CRM/Core/DAO/LocationType.php index b65a28cf97..5d280769f0 100644 --- a/CRM/Core/DAO/LocationType.php +++ b/CRM/Core/DAO/LocationType.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_LocationType extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -193,25 +187,16 @@ class CRM_Core_DAO_LocationType extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'display_name' => 'display_name', - 'vcard_name' => 'vcard_name', - 'description' => 'description', - 'is_reserved' => 'is_reserved', - 'is_active' => 'is_active', - 'is_default' => 'is_default', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/Log.php b/CRM/Core/DAO/Log.php index 36a6449778..90095fc3c4 100644 --- a/CRM/Core/DAO/Log.php +++ b/CRM/Core/DAO/Log.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_Log extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -180,23 +174,16 @@ class CRM_Core_DAO_Log extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'entity_table' => 'entity_table', - 'entity_id' => 'entity_id', - 'data' => 'data', - 'modified_id' => 'modified_id', - 'modified_date' => 'modified_date', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/MailSettings.php b/CRM/Core/DAO/MailSettings.php index 6bd4d77250..e2f5454e97 100644 --- a/CRM/Core/DAO/MailSettings.php +++ b/CRM/Core/DAO/MailSettings.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_MailSettings extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -302,31 +296,16 @@ class CRM_Core_DAO_MailSettings extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'domain_id' => 'domain_id', - 'name' => 'name', - 'is_default' => 'is_default', - 'domain' => 'domain', - 'localpart' => 'localpart', - 'return_path' => 'return_path', - 'protocol' => 'protocol', - 'server' => 'server', - 'port' => 'port', - 'username' => 'username', - 'password' => 'password', - 'is_ssl' => 'is_ssl', - 'source' => 'source', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/Managed.php b/CRM/Core/DAO/Managed.php index 5794a5b012..0cec98e7aa 100644 --- a/CRM/Core/DAO/Managed.php +++ b/CRM/Core/DAO/Managed.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_Managed extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -178,23 +172,16 @@ class CRM_Core_DAO_Managed extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'module' => 'module', - 'name' => 'name', - 'entity_type' => 'entity_type', - 'entity_id' => 'entity_id', - 'cleanup' => 'cleanup', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/Mapping.php b/CRM/Core/DAO/Mapping.php index c78a9e3e9a..66ffe71c91 100644 --- a/CRM/Core/DAO/Mapping.php +++ b/CRM/Core/DAO/Mapping.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_Mapping extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -148,21 +142,16 @@ class CRM_Core_DAO_Mapping extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'description' => 'description', - 'mapping_type_id' => 'mapping_type_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/MappingField.php b/CRM/Core/DAO/MappingField.php index ed6147f147..518195b7df 100644 --- a/CRM/Core/DAO/MappingField.php +++ b/CRM/Core/DAO/MappingField.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_MappingField extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -312,31 +306,16 @@ class CRM_Core_DAO_MappingField extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'mapping_id' => 'mapping_id', - 'name' => 'name', - 'contact_type' => 'contact_type', - 'column_number' => 'column_number', - 'location_type_id' => 'location_type_id', - 'phone_type_id' => 'phone_type_id', - 'im_provider_id' => 'im_provider_id', - 'website_type_id' => 'website_type_id', - 'relationship_type_id' => 'relationship_type_id', - 'relationship_direction' => 'relationship_direction', - 'grouping' => 'grouping', - 'operator' => 'operator', - 'value' => 'value', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/Menu.php b/CRM/Core/DAO/Menu.php index f0f7835fbd..8433f57c8d 100644 --- a/CRM/Core/DAO/Menu.php +++ b/CRM/Core/DAO/Menu.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -385,38 +379,16 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'domain_id' => 'domain_id', - 'path' => 'path', - 'path_arguments' => 'path_arguments', - 'title' => 'title', - 'access_callback' => 'access_callback', - 'access_arguments' => 'access_arguments', - 'page_callback' => 'page_callback', - 'page_arguments' => 'page_arguments', - 'breadcrumb' => 'breadcrumb', - 'return_url' => 'return_url', - 'return_url_args' => 'return_url_args', - 'component_id' => 'component_id', - 'is_active' => 'is_active', - 'is_public' => 'is_public', - 'is_exposed' => 'is_exposed', - 'is_ssl' => 'is_ssl', - 'weight' => 'weight', - 'type' => 'type', - 'page_type' => 'page_type', - 'skipBreadcrumb' => 'skipBreadcrumb', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/MessageTemplate.php b/CRM/Core/DAO/MessageTemplate.php index 7b953b776a..5bc734e14b 100644 --- a/CRM/Core/DAO/MessageTemplate.php +++ b/CRM/Core/DAO/MessageTemplate.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_MessageTemplate extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -234,28 +228,16 @@ class CRM_Core_DAO_MessageTemplate extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'msg_title' => 'msg_title', - 'msg_subject' => 'msg_subject', - 'msg_text' => 'msg_text', - 'msg_html' => 'msg_html', - 'is_active' => 'is_active', - 'workflow_id' => 'workflow_id', - 'is_default' => 'is_default', - 'is_reserved' => 'is_reserved', - 'is_sms' => 'is_sms', - 'pdf_format_id' => 'pdf_format_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/Navigation.php b/CRM/Core/DAO/Navigation.php index b1cdb593a7..6bd4ef8ebd 100644 --- a/CRM/Core/DAO/Navigation.php +++ b/CRM/Core/DAO/Navigation.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_Navigation extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -256,28 +250,16 @@ class CRM_Core_DAO_Navigation extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'domain_id' => 'domain_id', - 'label' => 'label', - 'name' => 'name', - 'url' => 'url', - 'permission' => 'permission', - 'permission_operator' => 'permission_operator', - 'parent_id' => 'parent_id', - 'is_active' => 'is_active', - 'has_separator' => 'has_separator', - 'weight' => 'weight', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/Note.php b/CRM/Core/DAO/Note.php index bab337d232..9a4a3e145a 100644 --- a/CRM/Core/DAO/Note.php +++ b/CRM/Core/DAO/Note.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_Note extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -228,25 +222,16 @@ class CRM_Core_DAO_Note extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'entity_table' => 'entity_table', - 'entity_id' => 'entity_id', - 'note' => 'note', - 'contact_id' => 'contact_id', - 'modified_date' => 'modified_date', - 'subject' => 'subject', - 'privacy' => 'privacy', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/OpenID.php b/CRM/Core/DAO/OpenID.php index f46e9218ee..66345571f4 100644 --- a/CRM/Core/DAO/OpenID.php +++ b/CRM/Core/DAO/OpenID.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_OpenID extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -184,23 +178,16 @@ class CRM_Core_DAO_OpenID extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'contact_id' => 'contact_id', - 'location_type_id' => 'location_type_id', - 'openid' => 'openid', - 'allowed_to_login' => 'allowed_to_login', - 'is_primary' => 'is_primary', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/OptionGroup.php b/CRM/Core/DAO/OptionGroup.php index da20016091..4ba6118492 100644 --- a/CRM/Core/DAO/OptionGroup.php +++ b/CRM/Core/DAO/OptionGroup.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_OptionGroup extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -181,24 +175,16 @@ class CRM_Core_DAO_OptionGroup extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'title' => 'title', - 'description' => 'description', - 'is_reserved' => 'is_reserved', - 'is_active' => 'is_active', - 'is_locked' => 'is_locked', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/OptionValue.php b/CRM/Core/DAO/OptionValue.php index d50016e912..16d688fe73 100644 --- a/CRM/Core/DAO/OptionValue.php +++ b/CRM/Core/DAO/OptionValue.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_OptionValue extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -342,33 +336,16 @@ class CRM_Core_DAO_OptionValue extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'option_group_id' => 'option_group_id', - 'label' => 'label', - 'value' => 'value', - 'name' => 'name', - 'grouping' => 'grouping', - 'filter' => 'filter', - 'is_default' => 'is_default', - 'weight' => 'weight', - 'description' => 'description', - 'is_optgroup' => 'is_optgroup', - 'is_reserved' => 'is_reserved', - 'is_active' => 'is_active', - 'component_id' => 'component_id', - 'domain_id' => 'domain_id', - 'visibility_id' => 'visibility_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/Persistent.php b/CRM/Core/DAO/Persistent.php index e0df0794a8..d4dc2dc1f0 100644 --- a/CRM/Core/DAO/Persistent.php +++ b/CRM/Core/DAO/Persistent.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_Persistent extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -156,22 +150,16 @@ class CRM_Core_DAO_Persistent extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'context' => 'context', - 'name' => 'name', - 'data' => 'data', - 'is_config' => 'is_config', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/Phone.php b/CRM/Core/DAO/Phone.php index dedb23359e..baff5b289b 100644 --- a/CRM/Core/DAO/Phone.php +++ b/CRM/Core/DAO/Phone.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_Phone extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -260,27 +254,16 @@ class CRM_Core_DAO_Phone extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'contact_id' => 'contact_id', - 'location_type_id' => 'location_type_id', - 'is_primary' => 'is_primary', - 'is_billing' => 'is_billing', - 'mobile_provider_id' => 'mobile_provider_id', - 'phone' => 'phone', - 'phone_ext' => 'phone_ext', - 'phone_numeric' => 'phone_numeric', - 'phone_type_id' => 'phone_type_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/PreferencesDate.php b/CRM/Core/DAO/PreferencesDate.php index 483c70e07e..f71162bd0c 100644 --- a/CRM/Core/DAO/PreferencesDate.php +++ b/CRM/Core/DAO/PreferencesDate.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_PreferencesDate extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -182,24 +176,16 @@ class CRM_Core_DAO_PreferencesDate extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'description' => 'description', - 'start' => 'start', - 'end' => 'end', - 'date_format' => 'date_format', - 'time_format' => 'time_format', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/PrevNextCache.php b/CRM/Core/DAO/PrevNextCache.php index 6684c99bfd..c0e1709263 100644 --- a/CRM/Core/DAO/PrevNextCache.php +++ b/CRM/Core/DAO/PrevNextCache.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_PrevNextCache extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -175,24 +169,16 @@ class CRM_Core_DAO_PrevNextCache extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'entity_table' => 'entity_table', - 'entity_id1' => 'entity_id1', - 'entity_id2' => 'entity_id2', - 'cacheKey' => 'cacheKey', - 'data' => 'data', - 'is_selected' => 'is_selected', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/PrintLabel.php b/CRM/Core/DAO/PrintLabel.php index 91d69480e7..e85d4629af 100644 --- a/CRM/Core/DAO/PrintLabel.php +++ b/CRM/Core/DAO/PrintLabel.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_PrintLabel extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -256,28 +250,16 @@ class CRM_Core_DAO_PrintLabel extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'title' => 'title', - 'name' => 'name', - 'description' => 'description', - 'label_format_name' => 'label_format_name', - 'label_type_id' => 'label_type_id', - 'data' => 'data', - 'is_default' => 'is_default', - 'is_active' => 'is_active', - 'is_reserved' => 'is_reserved', - 'created_id' => 'created_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/RecurringEntity.php b/CRM/Core/DAO/RecurringEntity.php index d7ed30781c..7b0fe4e4a7 100644 --- a/CRM/Core/DAO/RecurringEntity.php +++ b/CRM/Core/DAO/RecurringEntity.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_RecurringEntity extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -153,22 +147,16 @@ class CRM_Core_DAO_RecurringEntity extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'parent_id' => 'parent_id', - 'entity_id' => 'entity_id', - 'entity_table' => 'entity_table', - 'mode' => 'mode', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/Setting.php b/CRM/Core/DAO/Setting.php index 0af49a9132..801dc6cffc 100644 --- a/CRM/Core/DAO/Setting.php +++ b/CRM/Core/DAO/Setting.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_Setting extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -231,26 +225,16 @@ class CRM_Core_DAO_Setting extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'value' => 'value', - 'domain_id' => 'domain_id', - 'contact_id' => 'contact_id', - 'is_domain' => 'is_domain', - 'component_id' => 'component_id', - 'created_date' => 'created_date', - 'created_id' => 'created_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/StateProvince.php b/CRM/Core/DAO/StateProvince.php index 113a029f20..ff0d3b210e 100644 --- a/CRM/Core/DAO/StateProvince.php +++ b/CRM/Core/DAO/StateProvince.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_StateProvince extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -161,21 +155,16 @@ class CRM_Core_DAO_StateProvince extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'abbreviation' => 'abbreviation', - 'country_id' => 'country_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/StatusPreference.php b/CRM/Core/DAO/StatusPreference.php index 828ea5efec..8c55dd0af8 100644 --- a/CRM/Core/DAO/StatusPreference.php +++ b/CRM/Core/DAO/StatusPreference.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_StatusPreference extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -220,24 +214,16 @@ class CRM_Core_DAO_StatusPreference extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'domain_id' => 'domain_id', - 'name' => 'name', - 'hush_until' => 'hush_until', - 'ignore_severity' => 'ignore_severity', - 'prefs' => 'prefs', - 'check_info' => 'check_info', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/SystemLog.php b/CRM/Core/DAO/SystemLog.php index 5f00b39a87..ecb87a1294 100644 --- a/CRM/Core/DAO/SystemLog.php +++ b/CRM/Core/DAO/SystemLog.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_SystemLog extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -182,24 +176,16 @@ class CRM_Core_DAO_SystemLog extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'message' => 'message', - 'context' => 'context', - 'level' => 'level', - 'timestamp' => 'timestamp', - 'contact_id' => 'contact_id', - 'hostname' => 'hostname', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/Tag.php b/CRM/Core/DAO/Tag.php index 2670780d52..f2dae21406 100644 --- a/CRM/Core/DAO/Tag.php +++ b/CRM/Core/DAO/Tag.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_Tag extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -236,27 +230,16 @@ class CRM_Core_DAO_Tag extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'description' => 'description', - 'parent_id' => 'parent_id', - 'is_selectable' => 'is_selectable', - 'is_reserved' => 'is_reserved', - 'is_tagset' => 'is_tagset', - 'used_for' => 'used_for', - 'created_id' => 'created_id', - 'created_date' => 'created_date', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/Timezone.php b/CRM/Core/DAO/Timezone.php index 788ba9a2ff..2d34c34de7 100644 --- a/CRM/Core/DAO/Timezone.php +++ b/CRM/Core/DAO/Timezone.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_Timezone extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -180,23 +174,16 @@ class CRM_Core_DAO_Timezone extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'abbreviation' => 'abbreviation', - 'gmt' => 'gmt', - 'offset' => 'offset', - 'country_id' => 'country_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/UFField.php b/CRM/Core/DAO/UFField.php index e7b90635b4..d0ef03695d 100644 --- a/CRM/Core/DAO/UFField.php +++ b/CRM/Core/DAO/UFField.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_UFField extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -362,36 +356,16 @@ class CRM_Core_DAO_UFField extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'uf_group_id' => 'uf_group_id', - 'field_name' => 'field_name', - 'is_active' => 'is_active', - 'is_view' => 'is_view', - 'is_required' => 'is_required', - 'weight' => 'weight', - 'help_post' => 'help_post', - 'help_pre' => 'help_pre', - 'visibility' => 'visibility', - 'in_selector' => 'in_selector', - 'is_searchable' => 'is_searchable', - 'location_type_id' => 'location_type_id', - 'phone_type_id' => 'phone_type_id', - 'website_type_id' => 'website_type_id', - 'label' => 'label', - 'field_type' => 'field_type', - 'is_reserved' => 'is_reserved', - 'is_multi_summary' => 'is_multi_summary', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/UFGroup.php b/CRM/Core/DAO/UFGroup.php index 5f9fd7946b..8e72eb2cf3 100644 --- a/CRM/Core/DAO/UFGroup.php +++ b/CRM/Core/DAO/UFGroup.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -413,40 +407,16 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'is_active' => 'is_active', - 'group_type' => 'group_type', - 'title' => 'title', - 'description' => 'description', - 'help_pre' => 'help_pre', - 'help_post' => 'help_post', - 'limit_listings_group_id' => 'limit_listings_group_id', - 'post_URL' => 'post_URL', - 'add_to_group_id' => 'add_to_group_id', - 'add_captcha' => 'add_captcha', - 'is_map' => 'is_map', - 'is_edit_link' => 'is_edit_link', - 'is_uf_link' => 'is_uf_link', - 'is_update_dupe' => 'is_update_dupe', - 'cancel_URL' => 'cancel_URL', - 'is_cms_user' => 'is_cms_user', - 'notify' => 'notify', - 'is_reserved' => 'is_reserved', - 'name' => 'name', - 'created_id' => 'created_id', - 'created_date' => 'created_date', - 'is_proximity_search' => 'is_proximity_search', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/UFJoin.php b/CRM/Core/DAO/UFJoin.php index 27a7d86f4b..82f75371c3 100644 --- a/CRM/Core/DAO/UFJoin.php +++ b/CRM/Core/DAO/UFJoin.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_UFJoin extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -220,25 +214,16 @@ class CRM_Core_DAO_UFJoin extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'is_active' => 'is_active', - 'module' => 'module', - 'entity_table' => 'entity_table', - 'entity_id' => 'entity_id', - 'weight' => 'weight', - 'uf_group_id' => 'uf_group_id', - 'module_data' => 'module_data', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/UFMatch.php b/CRM/Core/DAO/UFMatch.php index 10b4fbc9db..ac0c2609bf 100644 --- a/CRM/Core/DAO/UFMatch.php +++ b/CRM/Core/DAO/UFMatch.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_UFMatch extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -188,23 +182,16 @@ class CRM_Core_DAO_UFMatch extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'domain_id' => 'domain_id', - 'uf_id' => 'uf_id', - 'uf_name' => 'uf_name', - 'contact_id' => 'contact_id', - 'language' => 'language', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/Website.php b/CRM/Core/DAO/Website.php index a99b7580e0..ab1c238ac4 100644 --- a/CRM/Core/DAO/Website.php +++ b/CRM/Core/DAO/Website.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_Website extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -168,21 +162,16 @@ class CRM_Core_DAO_Website extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'contact_id' => 'contact_id', - 'url' => 'url', - 'website_type_id' => 'website_type_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/WordReplacement.php b/CRM/Core/DAO/WordReplacement.php index 09c65a762f..38371de6c2 100644 --- a/CRM/Core/DAO/WordReplacement.php +++ b/CRM/Core/DAO/WordReplacement.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_WordReplacement extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -192,23 +186,16 @@ class CRM_Core_DAO_WordReplacement extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'find_word' => 'find_word', - 'replace_word' => 'replace_word', - 'is_active' => 'is_active', - 'match_type' => 'match_type', - 'domain_id' => 'domain_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Core/DAO/Worldregion.php b/CRM/Core/DAO/Worldregion.php index 901e8274f9..f3f97698ce 100644 --- a/CRM/Core/DAO/Worldregion.php +++ b/CRM/Core/DAO/Worldregion.php @@ -47,12 +47,6 @@ class CRM_Core_DAO_Worldregion extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -119,19 +113,16 @@ class CRM_Core_DAO_Worldregion extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'world_region', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Cxn/DAO/Cxn.php b/CRM/Cxn/DAO/Cxn.php index fb68a9edec..56550282ea 100644 --- a/CRM/Cxn/DAO/Cxn.php +++ b/CRM/Cxn/DAO/Cxn.php @@ -47,12 +47,6 @@ class CRM_Cxn_DAO_Cxn extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -232,28 +226,16 @@ class CRM_Cxn_DAO_Cxn extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'app_guid' => 'app_guid', - 'app_meta' => 'app_meta', - 'cxn_guid' => 'cxn_guid', - 'secret' => 'secret', - 'perm' => 'perm', - 'options' => 'options', - 'is_active' => 'is_active', - 'created_date' => 'created_date', - 'modified_date' => 'modified_date', - 'fetched_date' => 'fetched_date', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Dedupe/DAO/Exception.php b/CRM/Dedupe/DAO/Exception.php index 3c1252156e..ac2ee43d72 100644 --- a/CRM/Dedupe/DAO/Exception.php +++ b/CRM/Dedupe/DAO/Exception.php @@ -47,12 +47,6 @@ class CRM_Dedupe_DAO_Exception extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -141,20 +135,16 @@ class CRM_Dedupe_DAO_Exception extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'contact_id1' => 'contact_id1', - 'contact_id2' => 'contact_id2', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Dedupe/DAO/Rule.php b/CRM/Dedupe/DAO/Rule.php index 08469ab69b..0e80a60b8e 100644 --- a/CRM/Dedupe/DAO/Rule.php +++ b/CRM/Dedupe/DAO/Rule.php @@ -47,12 +47,6 @@ class CRM_Dedupe_DAO_Rule extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -189,23 +183,16 @@ class CRM_Dedupe_DAO_Rule extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'dedupe_rule_group_id' => 'dedupe_rule_group_id', - 'rule_table' => 'rule_table', - 'rule_field' => 'rule_field', - 'rule_length' => 'rule_length', - 'rule_weight' => 'rule_weight', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Dedupe/DAO/RuleGroup.php b/CRM/Dedupe/DAO/RuleGroup.php index b5b71fb8ec..d024449ebf 100644 --- a/CRM/Dedupe/DAO/RuleGroup.php +++ b/CRM/Dedupe/DAO/RuleGroup.php @@ -47,12 +47,6 @@ class CRM_Dedupe_DAO_RuleGroup extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -207,24 +201,16 @@ class CRM_Dedupe_DAO_RuleGroup extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'contact_type' => 'contact_type', - 'threshold' => 'threshold', - 'used' => 'used', - 'name' => 'name', - 'title' => 'title', - 'is_reserved' => 'is_reserved', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Event/Cart/DAO/Cart.php b/CRM/Event/Cart/DAO/Cart.php index 64441f3994..3eb2e1c90f 100644 --- a/CRM/Event/Cart/DAO/Cart.php +++ b/CRM/Event/Cart/DAO/Cart.php @@ -47,12 +47,6 @@ class CRM_Event_Cart_DAO_Cart extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -137,20 +131,16 @@ class CRM_Event_Cart_DAO_Cart extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'cart_id', - 'user_id' => 'user_id', - 'completed' => 'completed', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Event/Cart/DAO/EventInCart.php b/CRM/Event/Cart/DAO/EventInCart.php index f2e2d595f8..f60b8ce431 100644 --- a/CRM/Event/Cart/DAO/EventInCart.php +++ b/CRM/Event/Cart/DAO/EventInCart.php @@ -47,12 +47,6 @@ class CRM_Event_Cart_DAO_EventInCart extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -141,20 +135,16 @@ class CRM_Event_Cart_DAO_EventInCart extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'event_in_cart_id', - 'event_id' => 'event_id', - 'event_cart_id' => 'event_cart_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Event/DAO/Event.php b/CRM/Event/DAO/Event.php index 30973f607b..31acda1bda 100644 --- a/CRM/Event/DAO/Event.php +++ b/CRM/Event/DAO/Event.php @@ -47,12 +47,6 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -1262,86 +1256,16 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'title' => 'event_title', - 'summary' => 'summary', - 'description' => 'event_description', - 'event_type_id' => 'event_type_id', - 'participant_listing_id' => 'participant_listing_id', - 'is_public' => 'is_public', - 'start_date' => 'event_start_date', - 'end_date' => 'event_end_date', - 'is_online_registration' => 'is_online_registration', - 'registration_link_text' => 'registration_link_text', - 'registration_start_date' => 'registration_start_date', - 'registration_end_date' => 'registration_end_date', - 'max_participants' => 'max_participants', - 'event_full_text' => 'event_full_text', - 'is_monetary' => 'is_monetary', - 'financial_type_id' => 'financial_type_id', - 'payment_processor' => 'payment_processor', - 'is_map' => 'is_map', - 'is_active' => 'is_active', - 'fee_label' => 'fee_label', - 'is_show_location' => 'is_show_location', - 'loc_block_id' => 'loc_block_id', - 'default_role_id' => 'default_role_id', - 'intro_text' => 'intro_text', - 'footer_text' => 'footer_text', - 'confirm_title' => 'confirm_title', - 'confirm_text' => 'confirm_text', - 'confirm_footer_text' => 'confirm_footer_text', - 'is_email_confirm' => 'is_email_confirm', - 'confirm_email_text' => 'confirm_email_text', - 'confirm_from_name' => 'confirm_from_name', - 'confirm_from_email' => 'confirm_from_email', - 'cc_confirm' => 'cc_confirm', - 'bcc_confirm' => 'bcc_confirm', - 'default_fee_id' => 'default_fee_id', - 'default_discount_fee_id' => 'default_discount_fee_id', - 'thankyou_title' => 'thankyou_title', - 'thankyou_text' => 'thankyou_text', - 'thankyou_footer_text' => 'thankyou_footer_text', - 'is_pay_later' => 'is_pay_later', - 'pay_later_text' => 'pay_later_text', - 'pay_later_receipt' => 'pay_later_receipt', - 'is_partial_payment' => 'is_partial_payment', - 'initial_amount_label' => 'initial_amount_label', - 'initial_amount_help_text' => 'initial_amount_help_text', - 'min_initial_amount' => 'min_initial_amount', - 'is_multiple_registrations' => 'is_multiple_registrations', - 'max_additional_participants' => 'max_additional_participants', - 'allow_same_participant_emails' => 'allow_same_participant_emails', - 'has_waitlist' => 'has_waitlist', - 'requires_approval' => 'requires_approval', - 'expiration_time' => 'expiration_time', - 'allow_selfcancelxfer' => 'allow_selfcancelxfer', - 'selfcancelxfer_time' => 'selfcancelxfer_time', - 'waitlist_text' => 'waitlist_text', - 'approval_req_text' => 'approval_req_text', - 'is_template' => 'is_template', - 'template_title' => 'template_title', - 'created_id' => 'created_id', - 'created_date' => 'created_date', - 'currency' => 'currency', - 'campaign_id' => 'campaign_id', - 'is_share' => 'is_share', - 'is_confirm_enabled' => 'is_confirm_enabled', - 'parent_event_id' => 'parent_event_id', - 'slot_label_id' => 'slot_label_id', - 'dedupe_rule_group_id' => 'dedupe_rule_group_id', - 'is_billing_required' => 'is_billing_required', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Event/DAO/Participant.php b/CRM/Event/DAO/Participant.php index 61b4963d7f..7ad37cbcd2 100644 --- a/CRM/Event/DAO/Participant.php +++ b/CRM/Event/DAO/Participant.php @@ -47,12 +47,6 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -467,36 +461,16 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'participant_id', - 'contact_id' => 'participant_contact_id', - 'event_id' => 'event_id', - 'status_id' => 'participant_status_id', - 'role_id' => 'participant_role_id', - 'register_date' => 'participant_register_date', - 'source' => 'participant_source', - 'fee_level' => 'participant_fee_level', - 'is_test' => 'participant_is_test', - 'is_pay_later' => 'participant_is_pay_later', - 'fee_amount' => 'participant_fee_amount', - 'registered_by_id' => 'participant_registered_by_id', - 'discount_id' => 'participant_discount_id', - 'fee_currency' => 'participant_fee_currency', - 'campaign_id' => 'participant_campaign_id', - 'discount_amount' => 'discount_amount', - 'cart_id' => 'cart_id', - 'must_wait' => 'must_wait', - 'transferred_to_contact_id' => 'transferred_to_contact_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Event/DAO/ParticipantPayment.php b/CRM/Event/DAO/ParticipantPayment.php index 37f6ad8680..33e2e64f78 100644 --- a/CRM/Event/DAO/ParticipantPayment.php +++ b/CRM/Event/DAO/ParticipantPayment.php @@ -47,12 +47,6 @@ class CRM_Event_DAO_ParticipantPayment extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -143,20 +137,16 @@ class CRM_Event_DAO_ParticipantPayment extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'participant_id' => 'participant_id', - 'contribution_id' => 'contribution_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Event/DAO/ParticipantStatusType.php b/CRM/Event/DAO/ParticipantStatusType.php index 6073a64b01..bac7d1cc5b 100644 --- a/CRM/Event/DAO/ParticipantStatusType.php +++ b/CRM/Event/DAO/ParticipantStatusType.php @@ -47,12 +47,6 @@ class CRM_Event_DAO_ParticipantStatusType extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -223,26 +217,16 @@ class CRM_Event_DAO_ParticipantStatusType extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'participant_status', - 'label' => 'label', - 'class' => 'class', - 'is_reserved' => 'is_reserved', - 'is_active' => 'is_active', - 'is_counted' => 'is_counted', - 'weight' => 'weight', - 'visibility_id' => 'visibility_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Financial/DAO/Currency.php b/CRM/Financial/DAO/Currency.php index 79abca083a..cbcf6170ee 100644 --- a/CRM/Financial/DAO/Currency.php +++ b/CRM/Financial/DAO/Currency.php @@ -47,12 +47,6 @@ class CRM_Financial_DAO_Currency extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -176,22 +170,16 @@ class CRM_Financial_DAO_Currency extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'symbol' => 'symbol', - 'numeric_code' => 'numeric_code', - 'full_name' => 'full_name', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Financial/DAO/EntityFinancialAccount.php b/CRM/Financial/DAO/EntityFinancialAccount.php index 2ca5782bba..2284b8001e 100644 --- a/CRM/Financial/DAO/EntityFinancialAccount.php +++ b/CRM/Financial/DAO/EntityFinancialAccount.php @@ -47,12 +47,6 @@ class CRM_Financial_DAO_EntityFinancialAccount extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -190,22 +184,16 @@ class CRM_Financial_DAO_EntityFinancialAccount extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'entity_table' => 'entity_table', - 'entity_id' => 'entity_id', - 'account_relationship' => 'account_relationship', - 'financial_account_id' => 'financial_account_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Financial/DAO/EntityFinancialTrxn.php b/CRM/Financial/DAO/EntityFinancialTrxn.php index 7436aa893b..b5bde91ddc 100644 --- a/CRM/Financial/DAO/EntityFinancialTrxn.php +++ b/CRM/Financial/DAO/EntityFinancialTrxn.php @@ -47,12 +47,6 @@ class CRM_Financial_DAO_EntityFinancialTrxn extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -179,22 +173,16 @@ class CRM_Financial_DAO_EntityFinancialTrxn extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'entity_table' => 'entity_table', - 'entity_id' => 'entity_id', - 'financial_trxn_id' => 'financial_trxn_id', - 'amount' => 'amount', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Financial/DAO/FinancialAccount.php b/CRM/Financial/DAO/FinancialAccount.php index 53a1f55676..2eaab01205 100644 --- a/CRM/Financial/DAO/FinancialAccount.php +++ b/CRM/Financial/DAO/FinancialAccount.php @@ -47,12 +47,6 @@ class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -348,34 +342,16 @@ class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'contact_id' => 'financial_account_contact_id', - 'financial_account_type_id' => 'financial_account_type_id', - 'accounting_code' => 'accounting_code', - 'account_type_code' => 'account_type_code', - 'description' => 'description', - 'parent_id' => 'parent_id', - 'is_header_account' => 'is_header_account', - 'is_deductible' => 'is_deductible', - 'is_tax' => 'is_tax', - 'tax_rate' => 'tax_rate', - 'is_reserved' => 'is_reserved', - 'is_active' => 'is_active', - 'is_default' => 'is_default', - 'opening_balance' => 'opening_balance', - 'current_period_opening_balance' => 'current_period_opening_balance', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Financial/DAO/FinancialItem.php b/CRM/Financial/DAO/FinancialItem.php index 336e1ab9c4..81424f2c43 100644 --- a/CRM/Financial/DAO/FinancialItem.php +++ b/CRM/Financial/DAO/FinancialItem.php @@ -47,12 +47,6 @@ class CRM_Financial_DAO_FinancialItem extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -287,28 +281,16 @@ class CRM_Financial_DAO_FinancialItem extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'created_date' => 'created_date', - 'transaction_date' => 'transaction_date', - 'contact_id' => 'contact_id', - 'description' => 'description', - 'amount' => 'amount', - 'currency' => 'currency', - 'financial_account_id' => 'financial_account_id', - 'status_id' => 'status_id', - 'entity_table' => 'entity_table', - 'entity_id' => 'entity_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Financial/DAO/FinancialTrxn.php b/CRM/Financial/DAO/FinancialTrxn.php index bbe94b8afb..103a44c6da 100644 --- a/CRM/Financial/DAO/FinancialTrxn.php +++ b/CRM/Financial/DAO/FinancialTrxn.php @@ -47,12 +47,6 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -362,32 +356,16 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'from_financial_account_id' => 'from_financial_account_id', - 'to_financial_account_id' => 'to_financial_account_id', - 'trxn_date' => 'trxn_date', - 'total_amount' => 'total_amount', - 'fee_amount' => 'fee_amount', - 'net_amount' => 'net_amount', - 'currency' => 'currency', - 'is_payment' => 'is_payment', - 'trxn_id' => 'trxn_id', - 'trxn_result_code' => 'trxn_result_code', - 'status_id' => 'status_id', - 'payment_processor_id' => 'payment_processor_id', - 'payment_instrument_id' => 'financial_trxn_payment_instrument_id', - 'check_number' => 'financial_trxn_check_number', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Financial/DAO/FinancialType.php b/CRM/Financial/DAO/FinancialType.php index 0e557632d1..b6c467c5ce 100644 --- a/CRM/Financial/DAO/FinancialType.php +++ b/CRM/Financial/DAO/FinancialType.php @@ -47,12 +47,6 @@ class CRM_Financial_DAO_FinancialType extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -172,23 +166,16 @@ class CRM_Financial_DAO_FinancialType extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'financial_type', - 'description' => 'description', - 'is_deductible' => 'is_deductible', - 'is_reserved' => 'is_reserved', - 'is_active' => 'is_active', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Financial/DAO/PaymentProcessor.php b/CRM/Financial/DAO/PaymentProcessor.php index 1b5c73239b..e2d91e683f 100644 --- a/CRM/Financial/DAO/PaymentProcessor.php +++ b/CRM/Financial/DAO/PaymentProcessor.php @@ -47,12 +47,6 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -375,38 +369,16 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'domain_id' => 'domain_id', - 'name' => 'name', - 'description' => 'description', - 'payment_processor_type_id' => 'payment_processor_type_id', - 'is_active' => 'is_active', - 'is_default' => 'is_default', - 'is_test' => 'is_test', - 'user_name' => 'user_name', - 'password' => 'password', - 'signature' => 'signature', - 'url_site' => 'url_site', - 'url_api' => 'url_api', - 'url_recur' => 'url_recur', - 'url_button' => 'url_button', - 'subject' => 'subject', - 'class_name' => 'class_name', - 'billing_mode' => 'billing_mode', - 'is_recur' => 'is_recur', - 'payment_type' => 'payment_type', - 'payment_instrument_id' => 'payment_instrument_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Financial/DAO/PaymentProcessorType.php b/CRM/Financial/DAO/PaymentProcessorType.php index f578c3c986..d1ef543e35 100644 --- a/CRM/Financial/DAO/PaymentProcessorType.php +++ b/CRM/Financial/DAO/PaymentProcessorType.php @@ -47,12 +47,6 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -384,40 +378,16 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'title' => 'title', - 'description' => 'description', - 'is_active' => 'is_active', - 'is_default' => 'is_default', - 'user_name_label' => 'user_name_label', - 'password_label' => 'password_label', - 'signature_label' => 'signature_label', - 'subject_label' => 'subject_label', - 'class_name' => 'class_name', - 'url_site_default' => 'url_site_default', - 'url_api_default' => 'url_api_default', - 'url_recur_default' => 'url_recur_default', - 'url_button_default' => 'url_button_default', - 'url_site_test_default' => 'url_site_test_default', - 'url_api_test_default' => 'url_api_test_default', - 'url_recur_test_default' => 'url_recur_test_default', - 'url_button_test_default' => 'url_button_test_default', - 'billing_mode' => 'billing_mode', - 'is_recur' => 'is_recur', - 'payment_type' => 'payment_type', - 'payment_instrument_id' => 'payment_instrument_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Financial/DAO/PaymentToken.php b/CRM/Financial/DAO/PaymentToken.php index d1b6a6a2fd..acb6914b7a 100644 --- a/CRM/Financial/DAO/PaymentToken.php +++ b/CRM/Financial/DAO/PaymentToken.php @@ -47,12 +47,6 @@ class CRM_Financial_DAO_PaymentToken extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -279,30 +273,16 @@ class CRM_Financial_DAO_PaymentToken extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'payment_token_id', - 'contact_id' => 'contact_id', - 'payment_processor_id' => 'payment_processor_id', - 'token' => 'token', - 'created_date' => 'created_date', - 'created_id' => 'created_id', - 'expiry_date' => 'expiry_date', - 'email' => 'email', - 'billing_first_name' => 'billing_first_name', - 'billing_middle_name' => 'billing_middle_name', - 'billing_last_name' => 'billing_last_name', - 'masked_account_number' => 'masked_account_number', - 'ip_address' => 'ip_address', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Friend/DAO/Friend.php b/CRM/Friend/DAO/Friend.php index f8f303956d..105089037d 100644 --- a/CRM/Friend/DAO/Friend.php +++ b/CRM/Friend/DAO/Friend.php @@ -47,12 +47,6 @@ class CRM_Friend_DAO_Friend extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -254,27 +248,16 @@ class CRM_Friend_DAO_Friend extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'entity_table' => 'entity_table', - 'entity_id' => 'entity_id', - 'title' => 'title', - 'intro' => 'intro', - 'suggested_message' => 'suggested_message', - 'general_link' => 'general_link', - 'thankyou_title' => 'thankyou_title', - 'thankyou_text' => 'thankyou_text', - 'is_active' => 'is_active', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Grant/DAO/Grant.php b/CRM/Grant/DAO/Grant.php index 5bd37e837a..761ed0cbb4 100644 --- a/CRM/Grant/DAO/Grant.php +++ b/CRM/Grant/DAO/Grant.php @@ -47,12 +47,6 @@ class CRM_Grant_DAO_Grant extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -414,32 +408,16 @@ class CRM_Grant_DAO_Grant extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'grant_id', - 'contact_id' => 'grant_contact_id', - 'application_received_date' => 'application_received_date', - 'decision_date' => 'decision_date', - 'money_transfer_date' => 'grant_money_transfer_date', - 'grant_due_date' => 'grant_due_date', - 'grant_report_received' => 'grant_report_received', - 'grant_type_id' => 'grant_type_id', - 'amount_total' => 'amount_total', - 'amount_requested' => 'amount_requested', - 'amount_granted' => 'amount_granted', - 'currency' => 'currency', - 'rationale' => 'rationale', - 'status_id' => 'grant_status_id', - 'financial_type_id' => 'financial_type_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Mailing/DAO/BouncePattern.php b/CRM/Mailing/DAO/BouncePattern.php index da29da5070..127ebae861 100644 --- a/CRM/Mailing/DAO/BouncePattern.php +++ b/CRM/Mailing/DAO/BouncePattern.php @@ -47,12 +47,6 @@ class CRM_Mailing_DAO_BouncePattern extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -140,20 +134,16 @@ class CRM_Mailing_DAO_BouncePattern extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'bounce_type_id' => 'bounce_type_id', - 'pattern' => 'pattern', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Mailing/DAO/BounceType.php b/CRM/Mailing/DAO/BounceType.php index c31528c671..72848f53ae 100644 --- a/CRM/Mailing/DAO/BounceType.php +++ b/CRM/Mailing/DAO/BounceType.php @@ -47,12 +47,6 @@ class CRM_Mailing_DAO_BounceType extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -141,21 +135,16 @@ class CRM_Mailing_DAO_BounceType extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'description' => 'description', - 'hold_threshold' => 'hold_threshold', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Mailing/DAO/Component.php b/CRM/Mailing/DAO/Component.php index 8e71b90b97..75fe0a893d 100644 --- a/CRM/Mailing/DAO/Component.php +++ b/CRM/Mailing/DAO/Component.php @@ -47,12 +47,6 @@ class CRM_Mailing_DAO_Component extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -203,25 +197,16 @@ class CRM_Mailing_DAO_Component extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'component_type' => 'component_type', - 'subject' => 'subject', - 'body_html' => 'body_html', - 'body_text' => 'body_text', - 'is_default' => 'is_default', - 'is_active' => 'is_active', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Mailing/DAO/Mailing.php b/CRM/Mailing/DAO/Mailing.php index b6ee2d6497..11734073eb 100644 --- a/CRM/Mailing/DAO/Mailing.php +++ b/CRM/Mailing/DAO/Mailing.php @@ -47,12 +47,6 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -694,56 +688,16 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'domain_id' => 'domain_id', - 'header_id' => 'header_id', - 'footer_id' => 'footer_id', - 'reply_id' => 'reply_id', - 'unsubscribe_id' => 'unsubscribe_id', - 'resubscribe_id' => 'resubscribe_id', - 'optout_id' => 'optout_id', - 'name' => 'name', - 'mailing_type' => 'mailing_type', - 'from_name' => 'from_name', - 'from_email' => 'from_email', - 'replyto_email' => 'replyto_email', - 'subject' => 'subject', - 'body_text' => 'body_text', - 'body_html' => 'body_html', - 'url_tracking' => 'url_tracking', - 'forward_replies' => 'forward_replies', - 'auto_responder' => 'auto_responder', - 'open_tracking' => 'open_tracking', - 'is_completed' => 'is_completed', - 'msg_template_id' => 'msg_template_id', - 'override_verp' => 'override_verp', - 'created_id' => 'created_id', - 'created_date' => 'created_date', - 'scheduled_id' => 'scheduled_id', - 'scheduled_date' => 'scheduled_date', - 'approver_id' => 'approver_id', - 'approval_date' => 'approval_date', - 'approval_status_id' => 'approval_status_id', - 'approval_note' => 'approval_note', - 'is_archived' => 'is_archived', - 'visibility' => 'visibility', - 'campaign_id' => 'campaign_id', - 'dedupe_email' => 'dedupe_email', - 'sms_provider_id' => 'sms_provider_id', - 'hash' => 'hash', - 'location_type_id' => 'location_type_id', - 'email_selection_method' => 'email_selection_method', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Mailing/DAO/MailingAB.php b/CRM/Mailing/DAO/MailingAB.php index 910bce6e67..11adea7df6 100644 --- a/CRM/Mailing/DAO/MailingAB.php +++ b/CRM/Mailing/DAO/MailingAB.php @@ -47,12 +47,6 @@ class CRM_Mailing_DAO_MailingAB extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -285,31 +279,16 @@ class CRM_Mailing_DAO_MailingAB extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'status' => 'status', - 'mailing_id_a' => 'mailing_id_a', - 'mailing_id_b' => 'mailing_id_b', - 'mailing_id_c' => 'mailing_id_c', - 'domain_id' => 'domain_id', - 'testing_criteria' => 'testing_criteria', - 'winner_criteria' => 'winner_criteria', - 'specific_url' => 'specific_url', - 'declare_winning_time' => 'declare_winning_time', - 'group_percentage' => 'group_percentage', - 'created_id' => 'created_id', - 'created_date' => 'created_date', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Mailing/DAO/MailingGroup.php b/CRM/Mailing/DAO/MailingGroup.php index 461a041866..9e85d4a22f 100644 --- a/CRM/Mailing/DAO/MailingGroup.php +++ b/CRM/Mailing/DAO/MailingGroup.php @@ -47,12 +47,6 @@ class CRM_Mailing_DAO_MailingGroup extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -202,24 +196,16 @@ class CRM_Mailing_DAO_MailingGroup extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'mailing_id' => 'mailing_id', - 'group_type' => 'group_type', - 'entity_table' => 'entity_table', - 'entity_id' => 'entity_id', - 'search_id' => 'search_id', - 'search_args' => 'search_args', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Mailing/DAO/MailingJob.php b/CRM/Mailing/DAO/MailingJob.php index e90b1d2a32..b101953d96 100644 --- a/CRM/Mailing/DAO/MailingJob.php +++ b/CRM/Mailing/DAO/MailingJob.php @@ -47,12 +47,6 @@ class CRM_Mailing_DAO_MailingJob extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -247,28 +241,16 @@ class CRM_Mailing_DAO_MailingJob extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'mailing_id' => 'mailing_id', - 'scheduled_date' => 'scheduled_date', - 'start_date' => 'start_date', - 'end_date' => 'end_date', - 'status' => 'status', - 'is_test' => 'is_test', - 'job_type' => 'job_type', - 'parent_id' => 'parent_id', - 'job_offset' => 'job_offset', - 'job_limit' => 'job_limit', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Mailing/DAO/Recipients.php b/CRM/Mailing/DAO/Recipients.php index 7927419fca..989982a53a 100644 --- a/CRM/Mailing/DAO/Recipients.php +++ b/CRM/Mailing/DAO/Recipients.php @@ -47,12 +47,6 @@ class CRM_Mailing_DAO_Recipients extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -171,22 +165,16 @@ class CRM_Mailing_DAO_Recipients extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'mailing_id' => 'mailing_id', - 'contact_id' => 'contact_id', - 'email_id' => 'email_id', - 'phone_id' => 'phone_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Mailing/DAO/Spool.php b/CRM/Mailing/DAO/Spool.php index ee46e2c511..20dc068a4e 100644 --- a/CRM/Mailing/DAO/Spool.php +++ b/CRM/Mailing/DAO/Spool.php @@ -47,12 +47,6 @@ class CRM_Mailing_DAO_Spool extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -186,24 +180,16 @@ class CRM_Mailing_DAO_Spool extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'job_id' => 'job_id', - 'recipient_email' => 'recipient_email', - 'headers' => 'headers', - 'body' => 'body', - 'added_at' => 'added_at', - 'removed_at' => 'removed_at', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Mailing/DAO/TrackableURL.php b/CRM/Mailing/DAO/TrackableURL.php index bfc5809b67..b9d2e2aea9 100644 --- a/CRM/Mailing/DAO/TrackableURL.php +++ b/CRM/Mailing/DAO/TrackableURL.php @@ -47,12 +47,6 @@ class CRM_Mailing_DAO_TrackableURL extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -139,20 +133,16 @@ class CRM_Mailing_DAO_TrackableURL extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'url' => 'url', - 'mailing_id' => 'mailing_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Mailing/Event/DAO/Bounce.php b/CRM/Mailing/Event/DAO/Bounce.php index 893328a7ea..3a5cf486f0 100644 --- a/CRM/Mailing/Event/DAO/Bounce.php +++ b/CRM/Mailing/Event/DAO/Bounce.php @@ -47,12 +47,6 @@ class CRM_Mailing_Event_DAO_Bounce extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -173,22 +167,16 @@ class CRM_Mailing_Event_DAO_Bounce extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'event_queue_id' => 'event_queue_id', - 'bounce_type_id' => 'bounce_type_id', - 'bounce_reason' => 'bounce_reason', - 'time_stamp' => 'time_stamp', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Mailing/Event/DAO/Confirm.php b/CRM/Mailing/Event/DAO/Confirm.php index 7f82488fbd..6bd5c58abb 100644 --- a/CRM/Mailing/Event/DAO/Confirm.php +++ b/CRM/Mailing/Event/DAO/Confirm.php @@ -47,12 +47,6 @@ class CRM_Mailing_Event_DAO_Confirm extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -139,20 +133,16 @@ class CRM_Mailing_Event_DAO_Confirm extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'event_subscribe_id' => 'event_subscribe_id', - 'time_stamp' => 'time_stamp', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Mailing/Event/DAO/Delivered.php b/CRM/Mailing/Event/DAO/Delivered.php index dcc86b4602..9d6035e030 100644 --- a/CRM/Mailing/Event/DAO/Delivered.php +++ b/CRM/Mailing/Event/DAO/Delivered.php @@ -47,12 +47,6 @@ class CRM_Mailing_Event_DAO_Delivered extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -139,20 +133,16 @@ class CRM_Mailing_Event_DAO_Delivered extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'event_queue_id' => 'event_queue_id', - 'time_stamp' => 'time_stamp', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Mailing/Event/DAO/Forward.php b/CRM/Mailing/Event/DAO/Forward.php index 6cbfbdb19a..ec40a15ea3 100644 --- a/CRM/Mailing/Event/DAO/Forward.php +++ b/CRM/Mailing/Event/DAO/Forward.php @@ -47,12 +47,6 @@ class CRM_Mailing_Event_DAO_Forward extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -153,21 +147,16 @@ class CRM_Mailing_Event_DAO_Forward extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'event_queue_id' => 'event_queue_id', - 'dest_queue_id' => 'dest_queue_id', - 'time_stamp' => 'time_stamp', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Mailing/Event/DAO/Opened.php b/CRM/Mailing/Event/DAO/Opened.php index 8ea1b5c93d..6a07125eae 100644 --- a/CRM/Mailing/Event/DAO/Opened.php +++ b/CRM/Mailing/Event/DAO/Opened.php @@ -47,12 +47,6 @@ class CRM_Mailing_Event_DAO_Opened extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -139,20 +133,16 @@ class CRM_Mailing_Event_DAO_Opened extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'event_queue_id' => 'event_queue_id', - 'time_stamp' => 'time_stamp', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Mailing/Event/DAO/Queue.php b/CRM/Mailing/Event/DAO/Queue.php index 748802e882..c27df3561d 100644 --- a/CRM/Mailing/Event/DAO/Queue.php +++ b/CRM/Mailing/Event/DAO/Queue.php @@ -47,12 +47,6 @@ class CRM_Mailing_Event_DAO_Queue extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -186,23 +180,16 @@ class CRM_Mailing_Event_DAO_Queue extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'job_id' => 'job_id', - 'email_id' => 'email_id', - 'contact_id' => 'contact_id', - 'hash' => 'hash', - 'phone_id' => 'phone_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Mailing/Event/DAO/Reply.php b/CRM/Mailing/Event/DAO/Reply.php index 57c3b97d06..54908a8ff4 100644 --- a/CRM/Mailing/Event/DAO/Reply.php +++ b/CRM/Mailing/Event/DAO/Reply.php @@ -47,12 +47,6 @@ class CRM_Mailing_Event_DAO_Reply extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -139,20 +133,16 @@ class CRM_Mailing_Event_DAO_Reply extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'event_queue_id' => 'event_queue_id', - 'time_stamp' => 'time_stamp', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Mailing/Event/DAO/Subscribe.php b/CRM/Mailing/Event/DAO/Subscribe.php index ce895591a0..11fd6ecd58 100644 --- a/CRM/Mailing/Event/DAO/Subscribe.php +++ b/CRM/Mailing/Event/DAO/Subscribe.php @@ -47,12 +47,6 @@ class CRM_Mailing_Event_DAO_Subscribe extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -177,22 +171,16 @@ class CRM_Mailing_Event_DAO_Subscribe extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'group_id' => 'group_id', - 'contact_id' => 'contact_id', - 'hash' => 'hash', - 'time_stamp' => 'time_stamp', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Mailing/Event/DAO/TrackableURLOpen.php b/CRM/Mailing/Event/DAO/TrackableURLOpen.php index daf185d045..d753769020 100644 --- a/CRM/Mailing/Event/DAO/TrackableURLOpen.php +++ b/CRM/Mailing/Event/DAO/TrackableURLOpen.php @@ -47,12 +47,6 @@ class CRM_Mailing_Event_DAO_TrackableURLOpen extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -154,21 +148,16 @@ class CRM_Mailing_Event_DAO_TrackableURLOpen extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'event_queue_id' => 'event_queue_id', - 'trackable_url_id' => 'trackable_url_id', - 'time_stamp' => 'time_stamp', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Mailing/Event/DAO/Unsubscribe.php b/CRM/Mailing/Event/DAO/Unsubscribe.php index 65c0abd596..a98d39684e 100644 --- a/CRM/Mailing/Event/DAO/Unsubscribe.php +++ b/CRM/Mailing/Event/DAO/Unsubscribe.php @@ -47,12 +47,6 @@ class CRM_Mailing_Event_DAO_Unsubscribe extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -152,21 +146,16 @@ class CRM_Mailing_Event_DAO_Unsubscribe extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'event_queue_id' => 'event_queue_id', - 'org_unsubscribe' => 'org_unsubscribe', - 'time_stamp' => 'time_stamp', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Member/DAO/Membership.php b/CRM/Member/DAO/Membership.php index 2171426f3e..32e01a78e5 100644 --- a/CRM/Member/DAO/Membership.php +++ b/CRM/Member/DAO/Membership.php @@ -47,12 +47,6 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -407,32 +401,16 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'membership_id', - 'contact_id' => 'membership_contact_id', - 'membership_type_id' => 'membership_type_id', - 'join_date' => 'join_date', - 'start_date' => 'membership_start_date', - 'end_date' => 'membership_end_date', - 'source' => 'membership_source', - 'status_id' => 'status_id', - 'is_override' => 'is_override', - 'owner_membership_id' => 'owner_membership_id', - 'max_related' => 'max_related', - 'is_test' => 'member_is_test', - 'is_pay_later' => 'member_is_pay_later', - 'contribution_recur_id' => 'contribution_recur_id', - 'campaign_id' => 'member_campaign_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Member/DAO/MembershipBlock.php b/CRM/Member/DAO/MembershipBlock.php index 4c858d5197..6dcf57a271 100644 --- a/CRM/Member/DAO/MembershipBlock.php +++ b/CRM/Member/DAO/MembershipBlock.php @@ -47,12 +47,6 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -273,30 +267,16 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'entity_table' => 'entity_table', - 'entity_id' => 'entity_id', - 'membership_types' => 'membership_types', - 'membership_type_default' => 'membership_type_default', - 'display_min_fee' => 'display_min_fee', - 'is_separate_payment' => 'is_separate_payment', - 'new_title' => 'new_title', - 'new_text' => 'new_text', - 'renewal_title' => 'renewal_title', - 'renewal_text' => 'renewal_text', - 'is_required' => 'is_required', - 'is_active' => 'is_active', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Member/DAO/MembershipLog.php b/CRM/Member/DAO/MembershipLog.php index 73cca13349..c5066b1cc3 100644 --- a/CRM/Member/DAO/MembershipLog.php +++ b/CRM/Member/DAO/MembershipLog.php @@ -47,12 +47,6 @@ class CRM_Member_DAO_MembershipLog extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -217,26 +211,16 @@ class CRM_Member_DAO_MembershipLog extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'membership_id' => 'membership_id', - 'status_id' => 'status_id', - 'start_date' => 'start_date', - 'end_date' => 'end_date', - 'modified_id' => 'modified_id', - 'modified_date' => 'modified_date', - 'membership_type_id' => 'membership_type_id', - 'max_related' => 'max_related', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Member/DAO/MembershipPayment.php b/CRM/Member/DAO/MembershipPayment.php index da6c25ce8d..d182036e44 100644 --- a/CRM/Member/DAO/MembershipPayment.php +++ b/CRM/Member/DAO/MembershipPayment.php @@ -47,12 +47,6 @@ class CRM_Member_DAO_MembershipPayment extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -140,20 +134,16 @@ class CRM_Member_DAO_MembershipPayment extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'membership_id' => 'membership_id', - 'contribution_id' => 'contribution_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Member/DAO/MembershipStatus.php b/CRM/Member/DAO/MembershipStatus.php index e8cdf6501f..1c50b59147 100644 --- a/CRM/Member/DAO/MembershipStatus.php +++ b/CRM/Member/DAO/MembershipStatus.php @@ -47,12 +47,6 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -309,32 +303,16 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'membership_status', - 'label' => 'label', - 'start_event' => 'start_event', - 'start_event_adjust_unit' => 'start_event_adjust_unit', - 'start_event_adjust_interval' => 'start_event_adjust_interval', - 'end_event' => 'end_event', - 'end_event_adjust_unit' => 'end_event_adjust_unit', - 'end_event_adjust_interval' => 'end_event_adjust_interval', - 'is_current_member' => 'is_current_member', - 'is_admin' => 'is_admin', - 'weight' => 'weight', - 'is_default' => 'is_default', - 'is_active' => 'is_active', - 'is_reserved' => 'is_reserved', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Member/DAO/MembershipType.php b/CRM/Member/DAO/MembershipType.php index 0cad73d35c..e13b9c994c 100644 --- a/CRM/Member/DAO/MembershipType.php +++ b/CRM/Member/DAO/MembershipType.php @@ -47,12 +47,6 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -421,38 +415,16 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'domain_id' => 'domain_id', - 'name' => 'membership_type', - 'description' => 'description', - 'member_of_contact_id' => 'member_of_contact_id', - 'financial_type_id' => 'financial_type_id', - 'minimum_fee' => 'minimum_fee', - 'duration_unit' => 'duration_unit', - 'duration_interval' => 'duration_interval', - 'period_type' => 'period_type', - 'fixed_period_start_day' => 'fixed_period_start_day', - 'fixed_period_rollover_day' => 'fixed_period_rollover_day', - 'relationship_type_id' => 'relationship_type_id', - 'relationship_direction' => 'relationship_direction', - 'max_related' => 'max_related', - 'visibility' => 'visibility', - 'weight' => 'weight', - 'receipt_text_signup' => 'receipt_text_signup', - 'receipt_text_renewal' => 'receipt_text_renewal', - 'auto_renew' => 'auto_renew', - 'is_active' => 'is_active', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/PCP/DAO/PCP.php b/CRM/PCP/DAO/PCP.php index eedd42e78b..184e4fca91 100644 --- a/CRM/PCP/DAO/PCP.php +++ b/CRM/PCP/DAO/PCP.php @@ -47,12 +47,6 @@ class CRM_PCP_DAO_PCP extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -352,33 +346,16 @@ class CRM_PCP_DAO_PCP extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'pcp_id', - 'contact_id' => 'pcp_contact_id', - 'status_id' => 'status_id', - 'title' => 'title', - 'intro_text' => 'intro_text', - 'page_text' => 'page_text', - 'donate_link_text' => 'donate_link_text', - 'page_id' => 'page_id', - 'page_type' => 'page_type', - 'pcp_block_id' => 'pcp_block_id', - 'is_thermometer' => 'is_thermometer', - 'is_honor_roll' => 'is_honor_roll', - 'goal_amount' => 'goal_amount', - 'currency' => 'currency', - 'is_active' => 'is_active', - 'is_notify' => 'is_notify', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/PCP/DAO/PCPBlock.php b/CRM/PCP/DAO/PCPBlock.php index ec1c2b8a06..51c5f866bf 100644 --- a/CRM/PCP/DAO/PCPBlock.php +++ b/CRM/PCP/DAO/PCPBlock.php @@ -47,12 +47,6 @@ class CRM_PCP_DAO_PCPBlock extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -285,30 +279,16 @@ class CRM_PCP_DAO_PCPBlock extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'entity_table' => 'entity_table', - 'entity_id' => 'entity_id', - 'target_entity_type' => 'target_entity_type', - 'target_entity_id' => 'target_entity_id', - 'supporter_profile_id' => 'supporter_profile_id', - 'owner_notify_id' => 'owner_notify_id', - 'is_approval_needed' => 'is_approval_needed', - 'is_tellfriend_enabled' => 'is_tellfriend_enabled', - 'tellfriend_limit' => 'tellfriend_limit', - 'link_text' => 'link_text', - 'is_active' => 'is_active', - 'notify_email' => 'notify_email', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Pledge/DAO/Pledge.php b/CRM/Pledge/DAO/Pledge.php index 2f8a5a8bc2..60a589a0c0 100644 --- a/CRM/Pledge/DAO/Pledge.php +++ b/CRM/Pledge/DAO/Pledge.php @@ -47,12 +47,6 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -527,40 +521,16 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'pledge_id', - 'contact_id' => 'pledge_contact_id', - 'financial_type_id' => 'pledge_financial_type_id', - 'contribution_page_id' => 'pledge_contribution_page_id', - 'amount' => 'pledge_amount', - 'original_installment_amount' => 'pledge_original_installment_amount', - 'currency' => 'currency', - 'frequency_unit' => 'pledge_frequency_unit', - 'frequency_interval' => 'pledge_frequency_interval', - 'frequency_day' => 'frequency_day', - 'installments' => 'installments', - 'start_date' => 'start_date', - 'create_date' => 'pledge_create_date', - 'acknowledge_date' => 'acknowledge_date', - 'modified_date' => 'modified_date', - 'cancel_date' => 'cancel_date', - 'end_date' => 'end_date', - 'max_reminders' => 'max_reminders', - 'initial_reminder_day' => 'initial_reminder_day', - 'additional_reminder_day' => 'additional_reminder_day', - 'status_id' => 'pledge_status_id', - 'is_test' => 'pledge_is_test', - 'campaign_id' => 'pledge_campaign_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Pledge/DAO/PledgeBlock.php b/CRM/Pledge/DAO/PledgeBlock.php index 41159d1531..50b89493b0 100644 --- a/CRM/Pledge/DAO/PledgeBlock.php +++ b/CRM/Pledge/DAO/PledgeBlock.php @@ -47,12 +47,6 @@ class CRM_Pledge_DAO_PledgeBlock extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -246,28 +240,16 @@ class CRM_Pledge_DAO_PledgeBlock extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'entity_table' => 'entity_table', - 'entity_id' => 'entity_id', - 'pledge_frequency_unit' => 'pledge_frequency_unit', - 'is_pledge_interval' => 'is_pledge_interval', - 'max_reminders' => 'max_reminders', - 'initial_reminder_day' => 'initial_reminder_day', - 'additional_reminder_day' => 'additional_reminder_day', - 'pledge_start_date' => 'pledge_start_date', - 'is_pledge_start_date_visible' => 'is_pledge_start_date_visible', - 'is_pledge_start_date_editable' => 'is_pledge_start_date_editable', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Pledge/DAO/PledgePayment.php b/CRM/Pledge/DAO/PledgePayment.php index b4f11f4ae0..98f60338da 100644 --- a/CRM/Pledge/DAO/PledgePayment.php +++ b/CRM/Pledge/DAO/PledgePayment.php @@ -47,12 +47,6 @@ class CRM_Pledge_DAO_PledgePayment extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -283,27 +277,16 @@ class CRM_Pledge_DAO_PledgePayment extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'pledge_payment_id', - 'pledge_id' => 'pledge_id', - 'contribution_id' => 'contribution_id', - 'scheduled_amount' => 'pledge_payment_scheduled_amount', - 'actual_amount' => 'pledge_payment_actual_amount', - 'currency' => 'currency', - 'scheduled_date' => 'pledge_payment_scheduled_date', - 'reminder_date' => 'pledge_payment_reminder_date', - 'reminder_count' => 'pledge_payment_reminder_count', - 'status_id' => 'pledge_payment_status_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Price/DAO/LineItem.php b/CRM/Price/DAO/LineItem.php index bb86f1b1fb..1e57610ecf 100644 --- a/CRM/Price/DAO/LineItem.php +++ b/CRM/Price/DAO/LineItem.php @@ -47,12 +47,6 @@ class CRM_Price_DAO_LineItem extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -344,31 +338,16 @@ class CRM_Price_DAO_LineItem extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'entity_table' => 'entity_table', - 'entity_id' => 'entity_id', - 'contribution_id' => 'contribution_id', - 'price_field_id' => 'price_field_id', - 'label' => 'label', - 'qty' => 'qty', - 'unit_price' => 'unit_price', - 'line_total' => 'line_total', - 'participant_count' => 'participant_count', - 'price_field_value_id' => 'price_field_value_id', - 'financial_type_id' => 'financial_type_id', - 'deductible_amount' => 'deductible_amount', - 'tax_amount' => 'tax_amount', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Price/DAO/PriceField.php b/CRM/Price/DAO/PriceField.php index 7c139a23de..af87460cb0 100644 --- a/CRM/Price/DAO/PriceField.php +++ b/CRM/Price/DAO/PriceField.php @@ -47,12 +47,6 @@ class CRM_Price_DAO_PriceField extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -381,34 +375,16 @@ class CRM_Price_DAO_PriceField extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'price_set_id' => 'price_set_id', - 'name' => 'name', - 'label' => 'label', - 'html_type' => 'html_type', - 'is_enter_qty' => 'is_enter_qty', - 'help_pre' => 'help_pre', - 'help_post' => 'help_post', - 'weight' => 'weight', - 'is_display_amounts' => 'is_display_amounts', - 'options_per_line' => 'options_per_line', - 'is_active' => 'is_active', - 'is_required' => 'is_required', - 'active_on' => 'active_on', - 'expire_on' => 'expire_on', - 'javascript' => 'javascript', - 'visibility_id' => 'visibility_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Price/DAO/PriceFieldValue.php b/CRM/Price/DAO/PriceFieldValue.php index 14c6b7446d..5081ef2d0a 100644 --- a/CRM/Price/DAO/PriceFieldValue.php +++ b/CRM/Price/DAO/PriceFieldValue.php @@ -47,12 +47,6 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -388,34 +382,16 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'price_field_id' => 'price_field_id', - 'name' => 'name', - 'label' => 'label', - 'description' => 'description', - 'help_pre' => 'help_pre', - 'help_post' => 'help_post', - 'amount' => 'amount', - 'count' => 'count', - 'max_value' => 'max_value', - 'weight' => 'weight', - 'membership_type_id' => 'membership_type_id', - 'membership_num_terms' => 'membership_num_terms', - 'is_default' => 'is_default', - 'is_active' => 'is_active', - 'financial_type_id' => 'financial_type_id', - 'deductible_amount' => 'deductible_amount', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Price/DAO/PriceSet.php b/CRM/Price/DAO/PriceSet.php index e8ca215ddf..dedd093acd 100644 --- a/CRM/Price/DAO/PriceSet.php +++ b/CRM/Price/DAO/PriceSet.php @@ -47,12 +47,6 @@ class CRM_Price_DAO_PriceSet extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -314,29 +308,16 @@ class CRM_Price_DAO_PriceSet extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'domain_id' => 'domain_id', - 'name' => 'name', - 'title' => 'title', - 'is_active' => 'is_active', - 'help_pre' => 'help_pre', - 'help_post' => 'help_post', - 'javascript' => 'javascript', - 'extends' => 'extends', - 'financial_type_id' => 'financial_type_id', - 'is_quick_config' => 'is_quick_config', - 'is_reserved' => 'is_reserved', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Price/DAO/PriceSetEntity.php b/CRM/Price/DAO/PriceSetEntity.php index feaa971e84..0d56840eba 100644 --- a/CRM/Price/DAO/PriceSetEntity.php +++ b/CRM/Price/DAO/PriceSetEntity.php @@ -47,12 +47,6 @@ class CRM_Price_DAO_PriceSetEntity extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -157,21 +151,16 @@ class CRM_Price_DAO_PriceSetEntity extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'entity_table' => 'entity_table', - 'entity_id' => 'entity_id', - 'price_set_id' => 'price_set_id', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Queue/DAO/QueueItem.php b/CRM/Queue/DAO/QueueItem.php index 8c64aeb381..d07c926ea7 100644 --- a/CRM/Queue/DAO/QueueItem.php +++ b/CRM/Queue/DAO/QueueItem.php @@ -47,12 +47,6 @@ class CRM_Queue_DAO_QueueItem extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -174,23 +168,16 @@ class CRM_Queue_DAO_QueueItem extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'queue_name' => 'queue_name', - 'weight' => 'weight', - 'submit_time' => 'submit_time', - 'release_time' => 'release_time', - 'data' => 'data', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/Report/DAO/ReportInstance.php b/CRM/Report/DAO/ReportInstance.php index 478666c7a3..3370048a17 100644 --- a/CRM/Report/DAO/ReportInstance.php +++ b/CRM/Report/DAO/ReportInstance.php @@ -47,12 +47,6 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -445,38 +439,16 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'domain_id' => 'domain_id', - 'title' => 'title', - 'report_id' => 'report_id', - 'name' => 'name', - 'args' => 'args', - 'description' => 'description', - 'permission' => 'permission', - 'grouprole' => 'grouprole', - 'form_values' => 'form_values', - 'is_active' => 'is_active', - 'created_id' => 'created_id', - 'owner_id' => 'owner_id', - 'email_subject' => 'email_subject', - 'email_to' => 'email_to', - 'email_cc' => 'email_cc', - 'header' => 'header', - 'footer' => 'footer', - 'navigation_id' => 'navigation_id', - 'drilldown_id' => 'drilldown_id', - 'is_reserved' => 'is_reserved', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table diff --git a/CRM/SMS/DAO/Provider.php b/CRM/SMS/DAO/Provider.php index 3f86628959..5606ad24d9 100644 --- a/CRM/SMS/DAO/Provider.php +++ b/CRM/SMS/DAO/Provider.php @@ -47,12 +47,6 @@ class CRM_SMS_DAO_Provider extends CRM_Core_DAO { * @var array */ static $_fields = null; - /** - * static instance to hold the keys used in $_fields for each field. - * - * @var array - */ - static $_fieldKeys = null; /** * static instance to hold the FK relationships * @@ -234,27 +228,16 @@ class CRM_SMS_DAO_Provider extends CRM_Core_DAO { return self::$_fields; } /** - * Returns an array containing, for each field, the arary key used for that - * field in self::$_fields. + * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array + * Array(string $name => string $uniqueName). */ static function &fieldKeys() { - if (!(self::$_fieldKeys)) { - self::$_fieldKeys = array( - 'id' => 'id', - 'name' => 'name', - 'title' => 'title', - 'username' => 'username', - 'password' => 'password', - 'api_type' => 'api_type', - 'api_url' => 'api_url', - 'api_params' => 'api_params', - 'is_default' => 'is_default', - 'is_active' => 'is_active', - ); + if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { + Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } - return self::$_fieldKeys; + return Civi::$statics[__CLASS__]['fieldKeys']; } /** * Returns the names of this table -- 2.25.1