Merge pull request #23939 from civicrm/5.51
[civicrm-core.git] / CRM / Core / BAO / Domain.php
index 59c1ace59d73f60912f1c8743c47290c2f53ba86..69595743d5d479190e622d3a92895abb29c0315a 100644 (file)
@@ -33,21 +33,27 @@ class CRM_Core_BAO_Domain extends CRM_Core_DAO_Domain {
    * @param CRM_Core_DAO_Domain $domain
    */
   public static function onPostSave($domain) {
+    // We want to clear out any cached tokens.
+    // Editing a domain is so rare we can risk being heavy handed.
+    Civi::cache('metadata')->clear();
     Civi::$statics[__CLASS__]['current'] = 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_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);
   }
 
   /**
@@ -144,8 +150,9 @@ class CRM_Core_BAO_Domain extends CRM_Core_DAO_Domain {
    * @param int $id
    *
    * @return CRM_Core_DAO_Domain
+   * @throws \CRM_Core_Exception
    */
-  public static function edit($params, $id) {
+  public static function edit($params, $id): CRM_Core_DAO_Domain {
     $params['id'] = $id;
     return self::writeRecord($params);
   }