[REF] - Deprecate & delegate BAO::retrieve
authorColeman Watts <coleman@civicrm.org>
Mon, 17 Jan 2022 20:31:24 +0000 (15:31 -0500)
committerColeman Watts <coleman@civicrm.org>
Thu, 3 Feb 2022 00:36:02 +0000 (19:36 -0500)
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.

51 files changed:
CRM/ACL/BAO/ACL.php
CRM/ACL/BAO/ACLEntityRole.php
CRM/Badge/BAO/Layout.php
CRM/Campaign/BAO/Campaign.php
CRM/Campaign/BAO/Survey.php
CRM/Contact/BAO/ContactType.php
CRM/Contact/BAO/Group.php
CRM/Contact/BAO/RelationshipType.php
CRM/Contact/BAO/SavedSearch.php
CRM/Contribute/BAO/ContributionSoft.php
CRM/Contribute/BAO/ManagePremiums.php
CRM/Contribute/BAO/Premium.php
CRM/Core/BAO/ActionSchedule.php
CRM/Core/BAO/CustomField.php
CRM/Core/BAO/CustomGroup.php
CRM/Core/BAO/CustomOption.php
CRM/Core/BAO/Domain.php
CRM/Core/BAO/Extension.php
CRM/Core/BAO/FinancialTrxn.php
CRM/Core/BAO/Job.php
CRM/Core/BAO/LocationType.php
CRM/Core/BAO/MailSettings.php
CRM/Core/BAO/Mapping.php
CRM/Core/BAO/MessageTemplate.php
CRM/Core/BAO/Navigation.php
CRM/Core/BAO/OptionGroup.php
CRM/Core/BAO/OptionValue.php
CRM/Core/BAO/PreferencesDate.php
CRM/Core/BAO/Tag.php
CRM/Core/BAO/UFField.php
CRM/Core/BAO/WordReplacement.php
CRM/Core/DAO.php
CRM/Event/BAO/Event.php
CRM/Event/BAO/ParticipantStatusType.php
CRM/Financial/BAO/FinancialAccount.php
CRM/Financial/BAO/FinancialItem.php
CRM/Financial/BAO/FinancialType.php
CRM/Financial/BAO/PaymentProcessor.php
CRM/Financial/BAO/PaymentProcessorType.php
CRM/Friend/BAO/Friend.php
CRM/Mailing/BAO/MailingComponent.php
CRM/Member/BAO/MembershipStatus.php
CRM/Member/BAO/MembershipType.php
CRM/Pledge/BAO/Pledge.php
CRM/Pledge/BAO/PledgeBlock.php
CRM/Pledge/BAO/PledgePayment.php
CRM/Price/BAO/LineItem.php
CRM/Price/BAO/PriceField.php
CRM/Price/BAO/PriceFieldValue.php
CRM/Price/BAO/PriceSet.php
CRM/Report/BAO/ReportInstance.php

index 17d1f313832b8f811f0ce88891eb76bbc4206800..ba4a67021d771888c29351cf27a8353944305443 100644 (file)
@@ -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);
   }
 
   /**
index 9e35298b6f67bb320bf845b79c98e54af945e491..9d577f56f6781036620d4fcae8ab7858b5b72f49 100644 (file)
@@ -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);
   }
 
   /**
index 2c0780e89e292cc637b1ca177d58b77901473ce8..a662445166bfc70642375e51c406d7f8ef98dec1 100644 (file)
 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);
   }
 
   /**
index c9808c5b070d70833540f2691a65eba1035fb2d0..a15195e734d0b9842c6d2b53cedd04195bcc99de 100644 (file)
@@ -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);
   }
 
   /**
index b05fce5c9611cbd00e09c1806f99c5fbfdc10f9c..2d34a5240ad759c19a9ab52de9cfee77ceb983ec 100644 (file)
 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);
   }
 
   /**
index 39d769660d3335b9f93f245b475d47f8688f3242..636173f38ef0673d14958cddd35fc054ffd5e77b 100644 (file)
 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);
   }
 
   /**
index 0342416cffd207e524d79fff15526364e1a40511..57b8fe9aec0ae2b4254c419e37e0cb02d1158824 100644 (file)
@@ -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);
   }
 
   /**
index 17e38025c008225d71ff2f4c617ec67658d360f8..0eea40fe5ad7a637f7db1e8bd376b150539ff72d 100644 (file)
@@ -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);
   }
 
   /**
index cd45672464f19273cb53554a8e4ac5e6869c0dfb..b3a10d44e7b1a38081930628ca3d8db932d4f654 100644 (file)
 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);
   }
 
   /**
index 7d93a9250a577dd9d54d6e1e27259c5273f72b27..3c7ea77885feb82eeb6f2a8f088cfbb5fd47a59a 100644 (file)
@@ -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);
   }
 
   /**
index 272222804d006ccb565fa3935876428b8076675b..a05daaad12d2f3dc6823369744d983bf8f684853 100644 (file)
@@ -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
    */
index 8440521b997daf324e09d90b83f60236fe8dd00d..42e21c9ae4496a465c546f88a222bf7318e590f6 100644 (file)
@@ -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);
   }
 
   /**
index 2520e5652ea27a3c944ba9b179b8ef8cda13d122..904120a64be2439219fcf4cb296e52d07bb22b42 100644 (file)
@@ -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);
   }
 
   /**
index ee68902d0b7c969ffff21cb37fee0a47e34f4edf..e33402b7b396a1cadbaa9364688e076116850110 100644 (file)
@@ -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);
   }
 
   /**
index 7a8ca08a4e3893c66944184d7a43a682cacfbd2a..d3b60e6e3debf67dc05ec97f144f01c42b4ca0d5 100644 (file)
@@ -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);
   }
 
   /**
index e44a2c8a83a38671373b8e551361d758795e45a5..26d64936496ef9a652d2a361d75af8771d0e83ff 100644 (file)
 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);
   }
 
   /**
index 59c1ace59d73f60912f1c8743c47290c2f53ba86..78cbac607db82ede60ae1199617f68e29a50b1b4 100644 (file)
@@ -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);
   }
 
   /**
index acb9f3910ec5de2c84eb656a8e325e3981826030..6c12a5139e03d23f1f0b5f86bb94ced7644c3d00 100644 (file)
 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);
   }
 
   /**
index 7cd00efb32fc027dab1bf3396ac4c6f35d9349f8..27a385df856bfa970444be772f7885e50561b0be 100644 (file)
@@ -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);
   }
 
   /**
index 331d5852d65cd78c80ec05413305d239152d4348..a8dbcdde44136b72eb8d49beadc2e1b0b5131a1a 100644 (file)
@@ -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);
   }
 
   /**
index 3e25675ce2ca315dcb8c70d3826bae33dcb63e96..337dd172790527b1d00ef391146389bbd4a169c3 100644 (file)
@@ -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);
   }
 
   /**
index aad1945bbc5edfb98fd99b00ee42a20088c4aa0e..f0752fb5430fca4ed6876fa05595c2caab35e1f5 100644 (file)
@@ -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);
   }
 
   /**
index b9d8c7d19ac4f5856c3d4390b1b8b78eb8157672..a00ead49f4c07b3fff4b271eea8f2dd4e1a6189d 100644 (file)
 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);
   }
 
   /**
index ab0f8e7b6e25638caaf298f0d2413a3e42235b0a..8e31a82a96c9ced88ebe6dc91554f0b3931fa463 100644 (file)
@@ -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);
   }
 
   /**
index 28499d367688d44ac9c66647b16edbb545085fd6..c0847180a617c2cbd0e69de09dc6e365f680690c 100644 (file)
@@ -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);
   }
 
   /**
index 420537a16666894785fe26dbf576585716d2ba5d..565c5cbd3e1ccc68a0ec72066b188322b26b3ab1 100644 (file)
 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);
   }
 
   /**
index d0ef5019ab9bd6aff8541a8a58596d402fd23dd4..0214ca3072b40739f0b1a2eca32dc873433c2e2f 100644 (file)
@@ -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);
   }
 
   /**
index 0ede5825b9ed3fa3fa627e3e1ab5ac3c81a9abee..66482c03f94ccd572406023db269fb7180ede296 100644 (file)
 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);
   }
 
   /**
index 32c92d5b7abc8f7e8ef5abfe7edbdbf440415606..494bd8510bc07d566eb9ad55c1d24c1e09eda70a 100644 (file)
@@ -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);
   }
 
   /**
index 4c273384c9f1fb08df837a3669dcf15b1bd3a654..443b516eadf4775ce0c645b73e1c75e29bf00d10 100644 (file)
@@ -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);
   }
 
   /**
index 8025bc2a45c33c1f91b985d44785ba16af4f413b..b4252a8bbea252c7606e10bb0b6dedca5c3f97e4 100644 (file)
 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);
   }
 
   /**
index 5eab8615f8dc1615136da8866f195648faff4b0c..13ce759fd3545bc9f65e6c3c80d4cd525fa24862 100644 (file)
@@ -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
    */
index 05353468aad4cfd3ec61e7d2e0b53057a4f72d16..ca212da132f1b3fa1e27f76ea1dff87281e21b5d 100644 (file)
@@ -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);
   }
 
   /**
index 47eae53235e010a6de600d5a38003502fcd052d7..bd773993e51f0778556eb7bd1440317a6038a34e 100644 (file)
@@ -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);
   }
 
   /**
index b7320514ac0352fe4d0bb3fabfdc221488af3373..19d6b3754f829b1b3ca7b523a1737b97b670ce4e 100644 (file)
 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);
   }
 
   /**
index 15879bd854d5a7bbf39736804c9812f59b59c9ba..a5a0182cacedac3bdcbd09c8a459465bd6f0e61d 100644 (file)
 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);
   }
 
   /**
index 2b3d81f5ece675d1453d589758326a537ade79f2..760e335240dfbe37a73ebb22630eb48d3d810e6a 100644 (file)
@@ -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);
   }
 
   /**
index f455c5e7fcdffe745c8d72efd241a046b17f94be..1fbfc1c9d35f7d16846d117592e39d92081fbe37 100644 (file)
@@ -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);
   }
 
   /**
index 62f4cd44a0cf3c65d3686b566b23fc4e644be56c..eabc80afda1c8e9682aae6e0e07986778388b535 100644 (file)
@@ -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);
   }
 
   /**
index 216242af2e86ed4e6dd8176e69129383a2171f2e..8e92204caa2a795645cf4c6bbb4a0ad847df760b 100644 (file)
@@ -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);
   }
 
   /**
index 006bb3aec8526556851ec0b6decfdf0d7634b546..96d3c8e6240bb9eac41e0ce84e76546ac1601404 100644 (file)
 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);
   }
 
   /**
index 7fa4a1248aadb1e30d96df72a49a7d2774df4f9e..f1850aa12aa73a50eff10461b13437d53ac0e6f9 100644 (file)
 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);
   }
 
   /**
index 3b77fa2875eeeeeb9fbff35a69f36148a7185af2..f73a0a10c416da2ca1337381cb5fbca0bee70f1f 100644 (file)
@@ -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);
   }
 
   /**
index bdc26352bdbb88e565c5eee1f3a72ea206f465d5..7af5004ce58f9c20a80b542d089727242945dc41 100644 (file)
@@ -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);
   }
 
   /**
index 55d0f4c7f4ec6ee1806fc3d173681353adf1034c..4cea3ce74c791b830ab05122b74c962b8509bea6 100644 (file)
 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);
   }
 
   /**
index ebacab842d784fdee93f7b82f5d508ddc7815b7d..b5097073653592836c9a9503a9a80defd7282b2d 100644 (file)
@@ -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);
   }
 
   /**
index ab096b848d4a81e1cb721a67926512e820b92509..22a420297892bcf8f06c90dc346d16978f175f48 100644 (file)
@@ -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);
   }
 
   /**
index bac6d7a1a6e1b04f6c09f4e6bc35abbf6a8ab9f1..6726f0b744c3eb3583644e7c6a17662ee911aa8d 100644 (file)
@@ -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);
   }
 
   /**
index 5df67efec829ad5482625d3daac366f7b63afa8a..53422f26c4998f63ab25bb3a2745f82800d321cb 100644 (file)
@@ -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);
   }
 
   /**
index 2070e2c9364d789e9aeda3b5e6b652b29d2c2d15..acc70725784d156c6c753aa2bc9efac89507e577 100644 (file)
@@ -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);
   }
 
   /**
index 9d755dabd06971c2ef80a665d9b836ef4e324116..9aa00c2e85d65c2be505db59865467063cf4d387 100644 (file)
@@ -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);
   }
 
   /**