From 4f9403042242c842c07e1170c12714bb50b391aa Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 17 Jan 2022 15:31:24 -0500 Subject: [PATCH] [REF] - Deprecate & delegate BAO::retrieve This function was spawned to every BAO by copy/paste but has limited usefulness. It should be deprecated in favor of the API & eventually removed. --- CRM/ACL/BAO/ACL.php | 13 ++++++++-- CRM/ACL/BAO/ACLEntityRole.php | 13 ++++++++-- CRM/Badge/BAO/Layout.php | 20 ++++------------ CRM/Campaign/BAO/Campaign.php | 25 +++++++------------ CRM/Campaign/BAO/Survey.php | 25 +++++++------------ CRM/Contact/BAO/ContactType.php | 22 +++++++---------- CRM/Contact/BAO/Group.php | 22 +++++++---------- CRM/Contact/BAO/RelationshipType.php | 21 +++++++--------- CRM/Contact/BAO/SavedSearch.php | 21 +++++++--------- CRM/Contribute/BAO/ContributionSoft.php | 21 +++++++--------- CRM/Contribute/BAO/ManagePremiums.php | 2 -- CRM/Contribute/BAO/Premium.php | 17 ++++--------- CRM/Core/BAO/ActionSchedule.php | 28 ++++++++-------------- CRM/Core/BAO/CustomField.php | 13 ++++++---- CRM/Core/BAO/CustomGroup.php | 15 +++++++----- CRM/Core/BAO/CustomOption.php | 17 ++++--------- CRM/Core/BAO/Domain.php | 15 +++++++----- CRM/Core/BAO/Extension.php | 22 +++++++---------- CRM/Core/BAO/FinancialTrxn.php | 21 +++++++--------- CRM/Core/BAO/Job.php | 24 +++++++------------ CRM/Core/BAO/LocationType.php | 22 +++++++---------- CRM/Core/BAO/MailSettings.php | 26 +++++++------------- CRM/Core/BAO/Mapping.php | 22 +++++++---------- CRM/Core/BAO/MessageTemplate.php | 21 +++++++--------- CRM/Core/BAO/Navigation.php | 26 ++++++++------------ CRM/Core/BAO/OptionGroup.php | 21 +++++++--------- CRM/Core/BAO/OptionValue.php | 21 +++++++--------- CRM/Core/BAO/PreferencesDate.php | 28 +++++++--------------- CRM/Core/BAO/Tag.php | 22 +++++++---------- CRM/Core/BAO/UFField.php | 15 +++++++----- CRM/Core/BAO/WordReplacement.php | 19 +++++++-------- CRM/Core/DAO.php | 4 ++-- CRM/Event/BAO/Event.php | 21 +++++++--------- CRM/Event/BAO/ParticipantStatusType.php | 22 ++++++++--------- CRM/Financial/BAO/FinancialAccount.php | 21 +++++++--------- CRM/Financial/BAO/FinancialItem.php | 21 +++++++--------- CRM/Financial/BAO/FinancialType.php | 21 +++++++--------- CRM/Financial/BAO/PaymentProcessor.php | 24 +++++++------------ CRM/Financial/BAO/PaymentProcessorType.php | 22 +++++++---------- CRM/Friend/BAO/Friend.php | 23 ++++++++---------- CRM/Mailing/BAO/MailingComponent.php | 21 +++++++--------- CRM/Member/BAO/MembershipStatus.php | 21 +++++++--------- CRM/Member/BAO/MembershipType.php | 21 +++++++--------- CRM/Pledge/BAO/Pledge.php | 23 +++++++----------- CRM/Pledge/BAO/PledgeBlock.php | 23 +++++++----------- CRM/Pledge/BAO/PledgePayment.php | 23 +++++++----------- CRM/Price/BAO/LineItem.php | 23 +++++++----------- CRM/Price/BAO/PriceField.php | 15 +++++++----- CRM/Price/BAO/PriceFieldValue.php | 17 ++++++------- CRM/Price/BAO/PriceSet.php | 15 +++++++----- CRM/Report/BAO/ReportInstance.php | 18 +++++++------- 51 files changed, 436 insertions(+), 583 deletions(-) diff --git a/CRM/ACL/BAO/ACL.php b/CRM/ACL/BAO/ACL.php index 17d1f31383..ba4a67021d 100644 --- a/CRM/ACL/BAO/ACL.php +++ b/CRM/ACL/BAO/ACL.php @@ -158,11 +158,20 @@ SELECT acl.* } /** + * Retrieve DB object and copy to defaults array. + * * @param array $params + * Array of criteria values. * @param array $defaults + * Array to be populated with found values. + * + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - CRM_Core_DAO::commonRetrieve('CRM_ACL_DAO_ACL', $params, $defaults); + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/ACL/BAO/ACLEntityRole.php b/CRM/ACL/BAO/ACLEntityRole.php index 9e35298b6f..9d577f56f6 100644 --- a/CRM/ACL/BAO/ACLEntityRole.php +++ b/CRM/ACL/BAO/ACLEntityRole.php @@ -42,11 +42,20 @@ class CRM_ACL_BAO_ACLEntityRole extends CRM_ACL_DAO_ACLEntityRole { } /** + * Retrieve DB object and copy to defaults array. + * * @param array $params + * Array of criteria values. * @param array $defaults + * Array to be populated with found values. + * + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - CRM_Core_DAO::commonRetrieve(__CLASS__, $params, $defaults); + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Badge/BAO/Layout.php b/CRM/Badge/BAO/Layout.php index 2c0780e89e..a662445166 100644 --- a/CRM/Badge/BAO/Layout.php +++ b/CRM/Badge/BAO/Layout.php @@ -17,26 +17,16 @@ class CRM_Badge_BAO_Layout extends CRM_Core_DAO_PrintLabel { /** - * Retrieve DB object based on input parameters. - * - * It also stores all the retrieved values in the default array. + * Retrieve DB object and copy to defaults array. * + * @deprecated * @param array $params - * (reference ) an assoc array of name/value pairs. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. * - * @return CRM_Core_DAO_PrintLabel|null - * object on success, null otherwise + * @return CRM_Core_DAO_PrintLabel|NULL */ - public static function retrieve(&$params, &$defaults) { - $printLabel = new CRM_Core_DAO_PrintLabel(); - $printLabel->copyValues($params); - if ($printLabel->find(TRUE)) { - CRM_Core_DAO::storeValues($printLabel, $defaults); - return $printLabel; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve('CRM_Core_DAO_PrintLabel', $params, $defaults); } /** diff --git a/CRM/Campaign/BAO/Campaign.php b/CRM/Campaign/BAO/Campaign.php index c9808c5b07..a15195e734 100644 --- a/CRM/Campaign/BAO/Campaign.php +++ b/CRM/Campaign/BAO/Campaign.php @@ -87,27 +87,20 @@ class CRM_Campaign_BAO_Campaign extends CRM_Campaign_DAO_Campaign { } /** - * Retrieve DB object based on input parameters. - * - * It also stores all the retrieved values in the default array. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return \CRM_Campaign_DAO_Campaign|null + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $campaign = new CRM_Campaign_DAO_Campaign(); - - $campaign->copyValues($params); - - if ($campaign->find(TRUE)) { - CRM_Core_DAO::storeValues($campaign, $defaults); - return $campaign; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Campaign/BAO/Survey.php b/CRM/Campaign/BAO/Survey.php index b05fce5c96..2d34a5240a 100644 --- a/CRM/Campaign/BAO/Survey.php +++ b/CRM/Campaign/BAO/Survey.php @@ -21,27 +21,20 @@ class CRM_Campaign_BAO_Survey extends CRM_Campaign_DAO_Survey implements Civi\Test\HookInterface { /** - * Retrieve DB object based on input parameters. - * - * It also stores all the retrieved values in the default array. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. + * + * @return self|null + * The DAO object, if found. * - * @return CRM_Campaign_DAO_Survey|null + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $dao = new CRM_Campaign_DAO_Survey(); - - $dao->copyValues($params); - - if ($dao->find(TRUE)) { - CRM_Core_DAO::storeValues($dao, $defaults); - return $dao; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Contact/BAO/ContactType.php b/CRM/Contact/BAO/ContactType.php index 39d769660d..636173f38e 100644 --- a/CRM/Contact/BAO/ContactType.php +++ b/CRM/Contact/BAO/ContactType.php @@ -17,24 +17,20 @@ class CRM_Contact_BAO_ContactType extends CRM_Contact_DAO_ContactType implements \Civi\Test\HookInterface { /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Contact_DAO_ContactType|null - * object on success, null otherwise + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $contactType = new CRM_Contact_DAO_ContactType(); - $contactType->copyValues($params); - if ($contactType->find(TRUE)) { - CRM_Core_DAO::storeValues($contactType, $defaults); - return $contactType; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Contact/BAO/Group.php b/CRM/Contact/BAO/Group.php index 0342416cff..57b8fe9aec 100644 --- a/CRM/Contact/BAO/Group.php +++ b/CRM/Contact/BAO/Group.php @@ -19,24 +19,20 @@ use Civi\Api4\Group; class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { /** - * Retrieve DB object based on input parameters. - * - * It also stores all the retrieved values in the default array. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. + * + * @return self|null + * The DAO object, if found. * - * @return CRM_Contact_BAO_Group + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $group = new CRM_Contact_DAO_Group(); - $group->copyValues($params); - if ($group->find(TRUE)) { - CRM_Core_DAO::storeValues($group, $defaults); - return $group; - } + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Contact/BAO/RelationshipType.php b/CRM/Contact/BAO/RelationshipType.php index 17e38025c0..0eea40fe5a 100644 --- a/CRM/Contact/BAO/RelationshipType.php +++ b/CRM/Contact/BAO/RelationshipType.php @@ -21,23 +21,20 @@ use Civi\Core\Event\PreEvent; class CRM_Contact_BAO_RelationshipType extends CRM_Contact_DAO_RelationshipType implements \Civi\Test\HookInterface { /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Contact_BAO_RelationshipType + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $relationshipType = new CRM_Contact_DAO_RelationshipType(); - $relationshipType->copyValues($params); - if ($relationshipType->find(TRUE)) { - CRM_Core_DAO::storeValues($relationshipType, $defaults); - return $relationshipType; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Contact/BAO/SavedSearch.php b/CRM/Contact/BAO/SavedSearch.php index cd45672464..b3a10d44e7 100644 --- a/CRM/Contact/BAO/SavedSearch.php +++ b/CRM/Contact/BAO/SavedSearch.php @@ -21,25 +21,20 @@ class CRM_Contact_BAO_SavedSearch extends CRM_Contact_DAO_SavedSearch { /** - * Retrieve DB object based on input parameters. - * - * It also stores all the retrieved values in the default array. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. + * + * @return self|null + * The DAO object, if found. * - * @return CRM_Contact_DAO_SavedSearch + * @deprecated */ public static function retrieve($params, &$defaults = []) { - $savedSearch = new CRM_Contact_DAO_SavedSearch(); - $savedSearch->copyValues($params); - if ($savedSearch->find(TRUE)) { - CRM_Core_DAO::storeValues($savedSearch, $defaults); - return $savedSearch; - } - return NULL; + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Contribute/BAO/ContributionSoft.php b/CRM/Contribute/BAO/ContributionSoft.php index 7d93a9250a..3c7ea77885 100644 --- a/CRM/Contribute/BAO/ContributionSoft.php +++ b/CRM/Contribute/BAO/ContributionSoft.php @@ -173,23 +173,20 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio } /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. + * + * @return self|null + * The DAO object, if found. * - * @return CRM_Contribute_BAO_ContributionSoft + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $contributionSoft = new CRM_Contribute_DAO_ContributionSoft(); - $contributionSoft->copyValues($params); - if ($contributionSoft->find(TRUE)) { - CRM_Core_DAO::storeValues($contributionSoft, $defaults); - return $contributionSoft; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Contribute/BAO/ManagePremiums.php b/CRM/Contribute/BAO/ManagePremiums.php index 272222804d..a05daaad12 100644 --- a/CRM/Contribute/BAO/ManagePremiums.php +++ b/CRM/Contribute/BAO/ManagePremiums.php @@ -30,9 +30,7 @@ class CRM_Contribute_BAO_ManagePremiums extends CRM_Contribute_BAO_Product { * * @deprecated * @param array $params - * (reference ) an assoc array of name/value pairs. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. * * @return CRM_Contribute_BAO_Product */ diff --git a/CRM/Contribute/BAO/Premium.php b/CRM/Contribute/BAO/Premium.php index 8440521b99..42e21c9ae4 100644 --- a/CRM/Contribute/BAO/Premium.php +++ b/CRM/Contribute/BAO/Premium.php @@ -24,23 +24,16 @@ class CRM_Contribute_BAO_Premium extends CRM_Contribute_DAO_Premium { private static $productInfo; /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * + * @deprecated * @param array $params - * (reference ) an assoc array of name/value pairs. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. * - * @return CRM_Contribute_DAO_Product + * @return CRM_Contribute_DAO_Product|NULL */ - public static function retrieve(&$params, &$defaults) { - $premium = new CRM_Contribute_DAO_Product(); - $premium->copyValues($params); - if ($premium->find(TRUE)) { - CRM_Core_DAO::storeValues($premium, $defaults); - return $premium; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve('CRM_Contribute_DAO_Product', $params, $defaults); } /** diff --git a/CRM/Core/BAO/ActionSchedule.php b/CRM/Core/BAO/ActionSchedule.php index 2520e5652e..904120a64b 100644 --- a/CRM/Core/BAO/ActionSchedule.php +++ b/CRM/Core/BAO/ActionSchedule.php @@ -182,31 +182,23 @@ FROM civicrm_action_schedule cas } /** - * Retrieve DB object based on input parameters. - * - * It also stores all the retrieved values in the default array. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. - * @param array $values - * (reference ) an assoc array to hold the flattened values. + * Array of criteria values. + * @param array $defaults + * Array to be populated with found values. + * + * @return self|null + * The DAO object, if found. * - * @return CRM_Core_DAO_ActionSchedule|null - * object on success, null otherwise + * @deprecated */ - public static function retrieve(&$params, &$values) { + public static function retrieve($params, &$defaults) { if (empty($params)) { return NULL; } - $actionSchedule = new CRM_Core_DAO_ActionSchedule(); - - $actionSchedule->copyValues($params); - - if ($actionSchedule->find(TRUE)) { - CRM_Core_DAO::storeValues($actionSchedule, $values); - return $actionSchedule; - } - return NULL; + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index ee68902d0b..e33402b7b3 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -184,17 +184,20 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { } /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * An assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Core_DAO_CustomField + * @return self|null + * The DAO object, if found. + * + * @deprecated */ public static function retrieve($params, &$defaults) { - return CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $params, $defaults); + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index 7a8ca08a4e..d3b60e6e3d 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -207,17 +207,20 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { } /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Core_DAO_CustomGroup + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - return CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomGroup', $params, $defaults); + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Core/BAO/CustomOption.php b/CRM/Core/BAO/CustomOption.php index e44a2c8a83..26d6493649 100644 --- a/CRM/Core/BAO/CustomOption.php +++ b/CRM/Core/BAO/CustomOption.php @@ -22,23 +22,16 @@ class CRM_Core_BAO_CustomOption { /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * + * @deprecated * @param array $params - * (reference ) an assoc array of name/value pairs. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. * - * @return CRM_Core_BAO_CustomOption + * @return CRM_Core_DAO_OptionValue|NULL */ - public static function retrieve(&$params, &$defaults) { - $customOption = new CRM_Core_DAO_OptionValue(); - $customOption->copyValues($params); - if ($customOption->find(TRUE)) { - CRM_Core_DAO::storeValues($customOption, $defaults); - return $customOption; - } - return NULL; + public static function retrieve($params, &$defaults) { + return CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_OptionValue', $params, $defaults); } /** diff --git a/CRM/Core/BAO/Domain.php b/CRM/Core/BAO/Domain.php index 59c1ace59d..78cbac607d 100644 --- a/CRM/Core/BAO/Domain.php +++ b/CRM/Core/BAO/Domain.php @@ -37,17 +37,20 @@ class CRM_Core_BAO_Domain extends CRM_Core_DAO_Domain { } /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Core_DAO_Domain + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - return CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_Domain', $params, $defaults); + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Core/BAO/Extension.php b/CRM/Core/BAO/Extension.php index acb9f3910e..6c12a5139e 100644 --- a/CRM/Core/BAO/Extension.php +++ b/CRM/Core/BAO/Extension.php @@ -21,24 +21,20 @@ class CRM_Core_BAO_Extension extends CRM_Core_DAO_Extension { /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Core_BAO_LocationType|null - * object on success, null otherwise + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $extension = new CRM_Core_DAO_Extension(); - $extension->copyValues($params); - if ($extension->find(TRUE)) { - CRM_Core_DAO::storeValues($extension, $defaults); - return $extension; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Core/BAO/FinancialTrxn.php b/CRM/Core/BAO/FinancialTrxn.php index 7cd00efb32..27a385df85 100644 --- a/CRM/Core/BAO/FinancialTrxn.php +++ b/CRM/Core/BAO/FinancialTrxn.php @@ -91,23 +91,20 @@ class CRM_Core_BAO_FinancialTrxn extends CRM_Financial_DAO_FinancialTrxn { } /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. + * + * @return self|null + * The DAO object, if found. * - * @return \CRM_Financial_DAO_FinancialTrxn + * @deprecated */ - public static function retrieve(&$params, &$defaults = []) { - $financialItem = new CRM_Financial_DAO_FinancialTrxn(); - $financialItem->copyValues($params); - if ($financialItem->find(TRUE)) { - CRM_Core_DAO::storeValues($financialItem, $defaults); - return $financialItem; - } - return NULL; + public static function retrieve($params, &$defaults = []) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Core/BAO/Job.php b/CRM/Core/BAO/Job.php index 331d5852d6..a8dbcdde44 100644 --- a/CRM/Core/BAO/Job.php +++ b/CRM/Core/BAO/Job.php @@ -37,26 +37,20 @@ class CRM_Core_BAO_Job extends CRM_Core_DAO_Job { } /** - * Retrieve DB object based on input parameters. - * - * It also stores all the retrieved values in the default array. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. + * + * @return self|null + * The DAO object, if found. * - * @return CRM_Core_DAO_Job|null - * object on success, null otherwise + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $job = new CRM_Core_DAO_Job(); - $job->copyValues($params); - if ($job->find(TRUE)) { - CRM_Core_DAO::storeValues($job, $defaults); - return $job; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Core/BAO/LocationType.php b/CRM/Core/BAO/LocationType.php index 3e25675ce2..337dd17279 100644 --- a/CRM/Core/BAO/LocationType.php +++ b/CRM/Core/BAO/LocationType.php @@ -27,24 +27,20 @@ class CRM_Core_BAO_LocationType extends CRM_Core_DAO_LocationType implements \Ci public static $_billingLocationType = NULL; /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Core_DAO_LocationType|null - * object on success, null otherwise + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $locationType = new CRM_Core_DAO_LocationType(); - $locationType->copyValues($params); - if ($locationType->find(TRUE)) { - CRM_Core_DAO::storeValues($locationType, $defaults); - return $locationType; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Core/BAO/MailSettings.php b/CRM/Core/BAO/MailSettings.php index aad1945bbc..f0752fb543 100644 --- a/CRM/Core/BAO/MailSettings.php +++ b/CRM/Core/BAO/MailSettings.php @@ -103,28 +103,20 @@ class CRM_Core_BAO_MailSettings extends CRM_Core_DAO_MailSettings { } /** - * Retrieve DB object based on input parameters. - * - * It also stores all the retrieved values in the default array. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Core_BAO_MailSettings + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $mailSettings = new CRM_Core_DAO_MailSettings(); - $mailSettings->copyValues($params); - - $result = NULL; - if ($mailSettings->find(TRUE)) { - CRM_Core_DAO::storeValues($mailSettings, $defaults); - $result = $mailSettings; - } - - return $result; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Core/BAO/Mapping.php b/CRM/Core/BAO/Mapping.php index b9d8c7d19a..a00ead49f4 100644 --- a/CRM/Core/BAO/Mapping.php +++ b/CRM/Core/BAO/Mapping.php @@ -17,24 +17,20 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping implements \Civi\Test\HookInterface { /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return object - * CRM_Core_DAO_Mapping object on success, otherwise NULL + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $mapping = new CRM_Core_DAO_Mapping(); - $mapping->copyValues($params); - if ($mapping->find(TRUE)) { - CRM_Core_DAO::storeValues($mapping, $defaults); - return $mapping; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Core/BAO/MessageTemplate.php b/CRM/Core/BAO/MessageTemplate.php index ab0f8e7b6e..8e31a82a96 100644 --- a/CRM/Core/BAO/MessageTemplate.php +++ b/CRM/Core/BAO/MessageTemplate.php @@ -27,23 +27,20 @@ require_once 'Mail/mime.php'; class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate implements \Civi\Test\HookInterface { /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Core_DAO_MessageTemplate + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $messageTemplates = new CRM_Core_DAO_MessageTemplate(); - $messageTemplates->copyValues($params); - if ($messageTemplates->find(TRUE)) { - CRM_Core_DAO::storeValues($messageTemplates, $defaults); - return $messageTemplates; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Core/BAO/Navigation.php b/CRM/Core/BAO/Navigation.php index 28499d3676..c0847180a6 100644 --- a/CRM/Core/BAO/Navigation.php +++ b/CRM/Core/BAO/Navigation.php @@ -75,27 +75,21 @@ class CRM_Core_BAO_Navigation extends CRM_Core_DAO_Navigation { } /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Core_BAO_Navigation|null - * object on success, NULL otherwise + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $navigation = new CRM_Core_DAO_Navigation(); - $navigation->copyValues($params); - - $navigation->domain_id = CRM_Core_Config::domainID(); - - if ($navigation->find(TRUE)) { - CRM_Core_DAO::storeValues($navigation, $defaults); - return $navigation; - } - return NULL; + public static function retrieve($params, &$defaults) { + $params['domain_id'] = CRM_Core_Config::domainID(); + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Core/BAO/OptionGroup.php b/CRM/Core/BAO/OptionGroup.php index 420537a166..565c5cbd3e 100644 --- a/CRM/Core/BAO/OptionGroup.php +++ b/CRM/Core/BAO/OptionGroup.php @@ -17,23 +17,20 @@ class CRM_Core_BAO_OptionGroup extends CRM_Core_DAO_OptionGroup implements \Civi\Test\HookInterface { /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Core_BAO_OptionGroup + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $optionGroup = new CRM_Core_DAO_OptionGroup(); - $optionGroup->copyValues($params); - if ($optionGroup->find(TRUE)) { - CRM_Core_DAO::storeValues($optionGroup, $defaults); - return $optionGroup; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Core/BAO/OptionValue.php b/CRM/Core/BAO/OptionValue.php index d0ef5019ab..0214ca3072 100644 --- a/CRM/Core/BAO/OptionValue.php +++ b/CRM/Core/BAO/OptionValue.php @@ -90,23 +90,20 @@ class CRM_Core_BAO_OptionValue extends CRM_Core_DAO_OptionValue { } /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Core_BAO_OptionValue + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $optionValue = new CRM_Core_DAO_OptionValue(); - $optionValue->copyValues($params); - if ($optionValue->find(TRUE)) { - CRM_Core_DAO::storeValues($optionValue, $defaults); - return $optionValue; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Core/BAO/PreferencesDate.php b/CRM/Core/BAO/PreferencesDate.php index 0ede5825b9..66482c03f9 100644 --- a/CRM/Core/BAO/PreferencesDate.php +++ b/CRM/Core/BAO/PreferencesDate.php @@ -17,30 +17,20 @@ class CRM_Core_BAO_PreferencesDate extends CRM_Core_DAO_PreferencesDate { /** - * Static holder for the default LT. - * @var string - */ - public static $_defaultPreferencesDate = NULL; - - /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Core_BAO_PreferencesDate|null - * object on success, null otherwise + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $dao = new CRM_Core_DAO_PreferencesDate(); - $dao->copyValues($params); - if ($dao->find(TRUE)) { - CRM_Core_DAO::storeValues($dao, $defaults); - return $dao; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Core/BAO/Tag.php b/CRM/Core/BAO/Tag.php index 32c92d5b7a..494bd8510b 100644 --- a/CRM/Core/BAO/Tag.php +++ b/CRM/Core/BAO/Tag.php @@ -22,24 +22,20 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { protected $tree; /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return object - * CRM_Core_DAO_Tag object on success, otherwise null + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $tag = new CRM_Core_DAO_Tag(); - $tag->copyValues($params); - if ($tag->find(TRUE)) { - CRM_Core_DAO::storeValues($tag, $defaults); - return $tag; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Core/BAO/UFField.php b/CRM/Core/BAO/UFField.php index 4c273384c9..443b516ead 100644 --- a/CRM/Core/BAO/UFField.php +++ b/CRM/Core/BAO/UFField.php @@ -114,17 +114,20 @@ class CRM_Core_BAO_UFField extends CRM_Core_DAO_UFField { } /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Core_BAO_UFField + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - return CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_UFField', $params, $defaults); + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Core/BAO/WordReplacement.php b/CRM/Core/BAO/WordReplacement.php index 8025bc2a45..b4252a8bbe 100644 --- a/CRM/Core/BAO/WordReplacement.php +++ b/CRM/Core/BAO/WordReplacement.php @@ -21,21 +21,20 @@ class CRM_Core_BAO_WordReplacement extends CRM_Core_DAO_WordReplacement implements \Civi\Test\HookInterface { /** - * Function that must have never worked & should be removed. - * - * Retrieve DB object based on input parameters. - * - * It also stores all the retrieved values in the default array. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Core_DAO_WordReplacement + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - return CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_WordRepalcement', $params, $defaults); + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 5eab8615f8..13ce759fd3 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -1498,13 +1498,13 @@ LIKE %1 * Fetch object based on array of properties. * * @param string $daoName - * Name of the dao object. + * Name of the dao class. * @param array $params * (reference) an assoc array of name/value pairs. * @param array $defaults * (reference) an assoc array to hold the flattened values. * @param array $returnProperities - * An assoc array of fields that need to be returned, eg array( 'first_name', 'last_name'). + * An assoc array of fields that need to be returned, e.g. ['first_name', 'last_name']. * * @return static|null */ diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 05353468aa..ca212da132 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -18,23 +18,20 @@ class CRM_Event_BAO_Event extends CRM_Event_DAO_Event { const tz_fields = ['event_start_date', 'event_end_date', 'start_date', 'end_date', 'registration_start_date', 'registration_end_date']; /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Event_DAO_Event|null + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $event = new CRM_Event_DAO_Event(); - $event->copyValues($params); - if ($event->find(TRUE)) { - CRM_Core_DAO::storeValues($event, $defaults); - return $event; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Event/BAO/ParticipantStatusType.php b/CRM/Event/BAO/ParticipantStatusType.php index 47eae53235..bd773993e5 100644 --- a/CRM/Event/BAO/ParticipantStatusType.php +++ b/CRM/Event/BAO/ParticipantStatusType.php @@ -71,22 +71,20 @@ class CRM_Event_BAO_ParticipantStatusType extends CRM_Event_DAO_ParticipantStatu } /** + * Retrieve DB object and copy to defaults array. + * * @param array $params + * Array of criteria values. * @param array $defaults + * Array to be populated with found values. + * + * @return self|null + * The DAO object, if found. * - * @return CRM_Event_DAO_ParticipantStatusType|null + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $result = NULL; - - $dao = new CRM_Event_DAO_ParticipantStatusType(); - $dao->copyValues($params); - if ($dao->find(TRUE)) { - CRM_Core_DAO::storeValues($dao, $defaults); - $result = $dao; - } - - return $result; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Financial/BAO/FinancialAccount.php b/CRM/Financial/BAO/FinancialAccount.php index b7320514ac..19d6b3754f 100644 --- a/CRM/Financial/BAO/FinancialAccount.php +++ b/CRM/Financial/BAO/FinancialAccount.php @@ -17,23 +17,20 @@ class CRM_Financial_BAO_FinancialAccount extends CRM_Financial_DAO_FinancialAccount implements \Civi\Test\HookInterface { /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Financial_BAO_FinancialAccount + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults = []) { - $financialAccount = new CRM_Financial_DAO_FinancialAccount(); - $financialAccount->copyValues($params); - if ($financialAccount->find(TRUE)) { - CRM_Core_DAO::storeValues($financialAccount, $defaults); - return $financialAccount; - } - return NULL; + public static function retrieve($params, &$defaults = []) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Financial/BAO/FinancialItem.php b/CRM/Financial/BAO/FinancialItem.php index 15879bd854..a5a0182cac 100644 --- a/CRM/Financial/BAO/FinancialItem.php +++ b/CRM/Financial/BAO/FinancialItem.php @@ -17,23 +17,20 @@ class CRM_Financial_BAO_FinancialItem extends CRM_Financial_DAO_FinancialItem { /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Financial_DAO_FinancialItem + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $financialItem = new CRM_Financial_DAO_FinancialItem(); - $financialItem->copyValues($params); - if ($financialItem->find(TRUE)) { - CRM_Core_DAO::storeValues($financialItem, $defaults); - return $financialItem; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Financial/BAO/FinancialType.php b/CRM/Financial/BAO/FinancialType.php index 2b3d81f5ec..760e335240 100644 --- a/CRM/Financial/BAO/FinancialType.php +++ b/CRM/Financial/BAO/FinancialType.php @@ -32,23 +32,20 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType im public static $_statusACLFt = []; /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Financial_DAO_FinancialType + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $financialType = new CRM_Financial_DAO_FinancialType(); - $financialType->copyValues($params); - if ($financialType->find(TRUE)) { - CRM_Core_DAO::storeValues($financialType, $defaults); - return $financialType; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Financial/BAO/PaymentProcessor.php b/CRM/Financial/BAO/PaymentProcessor.php index f455c5e7fc..1fbfc1c9d3 100644 --- a/CRM/Financial/BAO/PaymentProcessor.php +++ b/CRM/Financial/BAO/PaymentProcessor.php @@ -127,26 +127,20 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces } /** - * Retrieve DB object based on input parameters. - * - * It also stores all the retrieved values in the default array. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Financial_DAO_PaymentProcessor|null - * object on success, null otherwise + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $paymentProcessor = new CRM_Financial_DAO_PaymentProcessor(); - $paymentProcessor->copyValues($params); - if ($paymentProcessor->find(TRUE)) { - CRM_Core_DAO::storeValues($paymentProcessor, $defaults); - return $paymentProcessor; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Financial/BAO/PaymentProcessorType.php b/CRM/Financial/BAO/PaymentProcessorType.php index 62f4cd44a0..eabc80afda 100644 --- a/CRM/Financial/BAO/PaymentProcessorType.php +++ b/CRM/Financial/BAO/PaymentProcessorType.php @@ -23,24 +23,20 @@ class CRM_Financial_BAO_PaymentProcessorType extends CRM_Financial_DAO_PaymentPr public static $_defaultPaymentProcessorType = NULL; /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. + * + * @return self|null + * The DAO object, if found. * - * @return CRM_Core_BAO_LocationType|null - * object on success, null otherwise + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $paymentProcessorType = new CRM_Financial_DAO_PaymentProcessorType(); - $paymentProcessorType->copyValues($params); - if ($paymentProcessorType->find(TRUE)) { - CRM_Core_DAO::storeValues($paymentProcessorType, $defaults); - return $paymentProcessorType; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Friend/BAO/Friend.php b/CRM/Friend/BAO/Friend.php index 216242af2e..8e92204caa 100644 --- a/CRM/Friend/BAO/Friend.php +++ b/CRM/Friend/BAO/Friend.php @@ -45,23 +45,20 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend { } /** - * Given the list of params in the params array, fetch the object - * and store the values in the values array + * Retrieve DB object and copy to defaults array. * * @param array $params - * Input parameters to find object. - * @param array $values - * Output values of the object. + * Array of criteria values. + * @param array $defaults + * Array to be populated with found values. + * + * @return self|null + * The DAO object, if found. * - * @return array - * values + * @deprecated */ - public static function retrieve(&$params, &$values) { - $friend = new CRM_Friend_DAO_Friend(); - $friend->copyValues($params); - $friend->find(TRUE); - CRM_Core_DAO::storeValues($friend, $values); - return $values; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Mailing/BAO/MailingComponent.php b/CRM/Mailing/BAO/MailingComponent.php index 006bb3aec8..96d3c8e624 100644 --- a/CRM/Mailing/BAO/MailingComponent.php +++ b/CRM/Mailing/BAO/MailingComponent.php @@ -17,23 +17,20 @@ class CRM_Mailing_BAO_MailingComponent extends CRM_Mailing_DAO_MailingComponent { /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. + * + * @return self|null + * The DAO object, if found. * - * @return CRM_Core_BAO_LocationType. + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $component = new CRM_Mailing_DAO_MailingComponent(); - $component->copyValues($params); - if ($component->find(TRUE)) { - CRM_Core_DAO::storeValues($component, $defaults); - return $component; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Member/BAO/MembershipStatus.php b/CRM/Member/BAO/MembershipStatus.php index 7fa4a1248a..f1850aa12a 100644 --- a/CRM/Member/BAO/MembershipStatus.php +++ b/CRM/Member/BAO/MembershipStatus.php @@ -17,23 +17,20 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus implements \Civi\Test\HookInterface { /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Member_BAO_MembershipStatus + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $membershipStatus = new CRM_Member_DAO_MembershipStatus(); - $membershipStatus->copyValues($params); - if ($membershipStatus->find(TRUE)) { - CRM_Core_DAO::storeValues($membershipStatus, $defaults); - return $membershipStatus; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Member/BAO/MembershipType.php b/CRM/Member/BAO/MembershipType.php index 3b77fa2875..f73a0a10c4 100644 --- a/CRM/Member/BAO/MembershipType.php +++ b/CRM/Member/BAO/MembershipType.php @@ -25,23 +25,20 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType implem public static $_membershipTypeInfo = []; /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Member_BAO_MembershipType + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $membershipType = new CRM_Member_DAO_MembershipType(); - $membershipType->copyValues($params); - if ($membershipType->find(TRUE)) { - CRM_Core_DAO::storeValues($membershipType, $defaults); - return $membershipType; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Pledge/BAO/Pledge.php b/CRM/Pledge/BAO/Pledge.php index bdc26352bd..7af5004ce5 100644 --- a/CRM/Pledge/BAO/Pledge.php +++ b/CRM/Pledge/BAO/Pledge.php @@ -24,25 +24,20 @@ class CRM_Pledge_BAO_Pledge extends CRM_Pledge_DAO_Pledge { public static $_exportableFields = NULL; /** - * Retrieve DB object based on input parameters. - * - * It also stores all the retrieved values in the default array. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. + * + * @return self|null + * The DAO object, if found. * - * @return CRM_Pledge_BAO_Pledge + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $pledge = new CRM_Pledge_DAO_Pledge(); - $pledge->copyValues($params); - if ($pledge->find(TRUE)) { - CRM_Core_DAO::storeValues($pledge, $defaults); - return $pledge; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Pledge/BAO/PledgeBlock.php b/CRM/Pledge/BAO/PledgeBlock.php index 55d0f4c7f4..4cea3ce74c 100644 --- a/CRM/Pledge/BAO/PledgeBlock.php +++ b/CRM/Pledge/BAO/PledgeBlock.php @@ -17,25 +17,20 @@ class CRM_Pledge_BAO_PledgeBlock extends CRM_Pledge_DAO_PledgeBlock { /** - * Retrieve DB object based on input parameters. - * - * It also stores all the retrieved values in the default array. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Pledge_BAO_PledgeBlock + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $pledgeBlock = new CRM_Pledge_DAO_PledgeBlock(); - $pledgeBlock->copyValues($params); - if ($pledgeBlock->find(TRUE)) { - CRM_Core_DAO::storeValues($pledgeBlock, $defaults); - return $pledgeBlock; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Pledge/BAO/PledgePayment.php b/CRM/Pledge/BAO/PledgePayment.php index ebacab842d..b509707365 100644 --- a/CRM/Pledge/BAO/PledgePayment.php +++ b/CRM/Pledge/BAO/PledgePayment.php @@ -171,25 +171,20 @@ WHERE pledge_id = %1 } /** - * Retrieve DB object based on input parameters. - * - * It also stores all the retrieved values in the default array. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. + * + * @return self|null + * The DAO object, if found. * - * @return CRM_Pledge_BAO_PledgePayment + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $payment = new CRM_Pledge_BAO_PledgePayment(); - $payment->copyValues($params); - if ($payment->find(TRUE)) { - CRM_Core_DAO::storeValues($payment, $defaults); - return $payment; - } - return NULL; + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Price/BAO/LineItem.php b/CRM/Price/BAO/LineItem.php index ab096b848d..22a4202978 100644 --- a/CRM/Price/BAO/LineItem.php +++ b/CRM/Price/BAO/LineItem.php @@ -97,25 +97,20 @@ class CRM_Price_BAO_LineItem extends CRM_Price_DAO_LineItem { } /** - * Retrieve DB object based on input parameters. - * - * It also stores all the retrieved values in the default array. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Price_BAO_LineItem + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params = [], &$defaults = []) { - $lineItem = new CRM_Price_BAO_LineItem(); - $lineItem->copyValues($params); - if ($lineItem->find(TRUE)) { - CRM_Core_DAO::storeValues($lineItem, $defaults); - return $lineItem; - } - return NULL; + public static function retrieve($params, &$defaults = []) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Price/BAO/PriceField.php b/CRM/Price/BAO/PriceField.php index bac6d7a1a6..6726f0b744 100644 --- a/CRM/Price/BAO/PriceField.php +++ b/CRM/Price/BAO/PriceField.php @@ -168,17 +168,20 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { } /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Price_DAO_PriceField + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - return CRM_Core_DAO::commonRetrieve('CRM_Price_DAO_PriceField', $params, $defaults); + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Price/BAO/PriceFieldValue.php b/CRM/Price/BAO/PriceFieldValue.php index 5df67efec8..53422f26c4 100644 --- a/CRM/Price/BAO/PriceFieldValue.php +++ b/CRM/Price/BAO/PriceFieldValue.php @@ -105,19 +105,20 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue { } /** - * Retrieve DB object based on input parameters. - * - * It also stores all the retrieved values in the default array. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Price_DAO_PriceFieldValue + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - return CRM_Core_DAO::commonRetrieve('CRM_Price_DAO_PriceFieldValue', $params, $defaults); + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Price/BAO/PriceSet.php b/CRM/Price/BAO/PriceSet.php index 2070e2c936..acc7072578 100644 --- a/CRM/Price/BAO/PriceSet.php +++ b/CRM/Price/BAO/PriceSet.php @@ -69,17 +69,20 @@ class CRM_Price_BAO_PriceSet extends CRM_Price_DAO_PriceSet { } /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Price_DAO_PriceSet + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - return CRM_Core_DAO::commonRetrieve('CRM_Price_DAO_PriceSet', $params, $defaults); + public static function retrieve($params, &$defaults) { + return self::commonRetrieve(self::class, $params, $defaults); } /** diff --git a/CRM/Report/BAO/ReportInstance.php b/CRM/Report/BAO/ReportInstance.php index 9d755dabd0..9aa00c2e85 100644 --- a/CRM/Report/BAO/ReportInstance.php +++ b/CRM/Report/BAO/ReportInstance.php @@ -243,22 +243,20 @@ class CRM_Report_BAO_ReportInstance extends CRM_Report_DAO_ReportInstance implem } /** - * Retrieve instance. + * Retrieve DB object and copy to defaults array. * * @param array $params + * Array of criteria values. * @param array $defaults + * Array to be populated with found values. * - * @return CRM_Report_DAO_ReportInstance|null + * @return self|null + * The DAO object, if found. + * + * @deprecated */ public static function retrieve($params, &$defaults) { - $instance = new CRM_Report_DAO_ReportInstance(); - $instance->copyValues($params); - - if ($instance->find(TRUE)) { - CRM_Core_DAO::storeValues($instance, $defaults); - return $instance; - } - return NULL; + return self::commonRetrieve(self::class, $params, $defaults); } /** -- 2.25.1