From: Coleman Watts Date: Sat, 1 Apr 2023 23:50:11 +0000 (-0400) Subject: BAO - deprecate create for writeRecord: SubscriptionHistory X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f540a6ef812f3a110246478c039e7b5b4dd81681;p=civicrm-core.git BAO - deprecate create for writeRecord: SubscriptionHistory --- diff --git a/CRM/Contact/BAO/SubscriptionHistory.php b/CRM/Contact/BAO/SubscriptionHistory.php index 5deb2c729f..10caeffe38 100644 --- a/CRM/Contact/BAO/SubscriptionHistory.php +++ b/CRM/Contact/BAO/SubscriptionHistory.php @@ -16,25 +16,30 @@ */ /** - * BAO object for crm_email table. + * BAO object for civicrm_subscription_history table. */ -class CRM_Contact_BAO_SubscriptionHistory extends CRM_Contact_DAO_SubscriptionHistory { +class CRM_Contact_BAO_SubscriptionHistory extends CRM_Contact_DAO_SubscriptionHistory implements \Civi\Core\HookInterface { /** - * Create a new subscription history record. - * + * @deprecated * @param array $params - * Values for the new history record. - * - * @return object - * $history The new history object + * @return CRM_Contact_DAO_SubscriptionHistory */ public static function create($params) { - $history = new CRM_Contact_BAO_SubscriptionHistory(); - $history->date = date('YmdHis'); - $history->copyValues($params); - $history->save(); - return $history; + return self::writeRecord($params); + } + + /** + * Callback for hook_civicrm_pre(). + * + * @param \Civi\Core\Event\PreEvent $event + * + * @throws \CRM_Core_Exception + */ + public static function self_hook_civicrm_pre(\Civi\Core\Event\PreEvent $event): void { + if ($event->action === 'create' || $event->action === 'edit') { + $event->params['date'] = date('YmdHis'); + } } /**