From 2528f3e9885d1e09eecdfa3ce949679b5f6a6916 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 9 Mar 2023 12:01:34 +1300 Subject: [PATCH] Remove deprecated calls from contribute, financial, remove ManagePremiums deprecated BAO --- CRM/Contribute/BAO/ManagePremiums.php | 92 -------------------- CRM/Contribute/BAO/Premium.php | 1 + CRM/Contribute/BAO/Product.php | 1 + CRM/Contribute/Form/ManagePremiums.php | 2 +- CRM/Extension/Manager.php | 7 +- CRM/Financial/BAO/EntityFinancialAccount.php | 2 +- CRM/Financial/BAO/FinancialAccount.php | 1 + CRM/Financial/BAO/FinancialType.php | 3 + CRM/Financial/Form/FinancialAccount.php | 2 +- CRM/Financial/Form/FinancialType.php | 8 +- 10 files changed, 18 insertions(+), 101 deletions(-) delete mode 100644 CRM/Contribute/BAO/ManagePremiums.php diff --git a/CRM/Contribute/BAO/ManagePremiums.php b/CRM/Contribute/BAO/ManagePremiums.php deleted file mode 100644 index a8e6033e70..0000000000 --- a/CRM/Contribute/BAO/ManagePremiums.php +++ /dev/null @@ -1,92 +0,0 @@ - $premiumID]); } diff --git a/CRM/Contribute/BAO/Product.php b/CRM/Contribute/BAO/Product.php index 7c7f9ff164..754106904e 100644 --- a/CRM/Contribute/BAO/Product.php +++ b/CRM/Contribute/BAO/Product.php @@ -110,6 +110,7 @@ class CRM_Contribute_BAO_Product extends CRM_Contribute_DAO_Product { * @throws \CRM_Core_Exception */ public static function del($productID) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); static::deleteRecord(['id' => $productID]); } diff --git a/CRM/Contribute/Form/ManagePremiums.php b/CRM/Contribute/Form/ManagePremiums.php index ab930809a8..965c67f4ae 100644 --- a/CRM/Contribute/Form/ManagePremiums.php +++ b/CRM/Contribute/Form/ManagePremiums.php @@ -259,7 +259,7 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form { // If deleting, then only delete and skip the rest of the post-processing if ($this->_action & CRM_Core_Action::DELETE) { try { - CRM_Contribute_BAO_Product::del($this->_id); + CRM_Contribute_BAO_Product::deleteRecord(['id' => $this->_id]); } catch (CRM_Core_Exception $e) { $message = ts("This Premium is linked to an Online Contribution page. Please remove it before deleting this Premium.", [1 => CRM_Utils_System::url('civicrm/admin/contribute', 'reset=1')]); diff --git a/CRM/Extension/Manager.php b/CRM/Extension/Manager.php index b64bcc23f1..6b1f1cfb59 100644 --- a/CRM/Extension/Manager.php +++ b/CRM/Extension/Manager.php @@ -700,11 +700,12 @@ class CRM_Extension_Manager { $dao = new CRM_Core_DAO_Extension(); $dao->full_name = $info->key; if ($dao->find(TRUE)) { - if (CRM_Core_BAO_Extension::del($dao->id)) { + try { + CRM_Core_BAO_Extension::deleteRecord(['id' => $dao->id]); CRM_Core_Session::setStatus(ts('Selected option value has been deleted.'), ts('Deleted'), 'success'); } - else { - throw new CRM_Extension_Exception("Failed to remove extension entry"); + catch (CRM_Core_Exception $e) { + throw new CRM_Extension_Exception("Failed to remove extension entry $dao->id"); } } // else: post-condition already satisified } diff --git a/CRM/Financial/BAO/EntityFinancialAccount.php b/CRM/Financial/BAO/EntityFinancialAccount.php index c2d8839d5d..283247a516 100644 --- a/CRM/Financial/BAO/EntityFinancialAccount.php +++ b/CRM/Financial/BAO/EntityFinancialAccount.php @@ -205,7 +205,7 @@ class CRM_Financial_BAO_EntityFinancialAccount extends CRM_Financial_DAO_EntityF 'account_type_code' => 'INC', 'is_active' => 1, ]; - $financialAccount = CRM_Financial_BAO_FinancialAccount::add($params); + $financialAccount = CRM_Financial_BAO_FinancialAccount::writeRecord($params); } else { $existingFinancialAccount[$dao->financial_account_type_id] = $dao->id; diff --git a/CRM/Financial/BAO/FinancialAccount.php b/CRM/Financial/BAO/FinancialAccount.php index 77f65011ac..5e04cda5c2 100644 --- a/CRM/Financial/BAO/FinancialAccount.php +++ b/CRM/Financial/BAO/FinancialAccount.php @@ -57,6 +57,7 @@ class CRM_Financial_BAO_FinancialAccount extends CRM_Financial_DAO_FinancialAcco * @return CRM_Financial_DAO_FinancialAccount */ public static function add($params) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return self::writeRecord($params); } diff --git a/CRM/Financial/BAO/FinancialType.php b/CRM/Financial/BAO/FinancialType.php index e832df68ae..d02b7c8fe8 100644 --- a/CRM/Financial/BAO/FinancialType.php +++ b/CRM/Financial/BAO/FinancialType.php @@ -71,6 +71,7 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType im * @deprecated */ public static function create(array $params) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return self::writeRecord($params); } @@ -88,6 +89,7 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType im * @deprecated */ public static function add(array $params, $ids = []) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); return self::writeRecord($params); } @@ -99,6 +101,7 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType im * @return array|bool */ public static function del($financialTypeId) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); try { static::deleteRecord(['id' => $financialTypeId]); return TRUE; diff --git a/CRM/Financial/Form/FinancialAccount.php b/CRM/Financial/Form/FinancialAccount.php index 8c52ce6fc2..c90572a326 100644 --- a/CRM/Financial/Form/FinancialAccount.php +++ b/CRM/Financial/Form/FinancialAccount.php @@ -209,7 +209,7 @@ class CRM_Financial_Form_FinancialAccount extends CRM_Contribute_Form { ] as $field) { $params[$field] = CRM_Utils_Array::value($field, $params, FALSE); } - $financialAccount = CRM_Financial_BAO_FinancialAccount::add($params); + $financialAccount = CRM_Financial_BAO_FinancialAccount::writeRecord($params); CRM_Core_Session::setStatus(ts('The Financial Account \'%1\' has been saved.', [1 => $financialAccount->name]), ts('Saved'), 'success'); } } diff --git a/CRM/Financial/Form/FinancialType.php b/CRM/Financial/Form/FinancialType.php index 9d1c0fdfb6..a9cd27ee26 100644 --- a/CRM/Financial/Form/FinancialType.php +++ b/CRM/Financial/Form/FinancialType.php @@ -117,9 +117,11 @@ class CRM_Financial_Form_FinancialType extends CRM_Core_Form { */ public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { - $errors = CRM_Financial_BAO_FinancialType::del($this->_id); - if (is_array($errors) && !empty($errors)) { - CRM_Core_Error::statusBounce($errors['error_message'], CRM_Utils_System::url('civicrm/admin/financial/financialType', "reset=1&action=browse"), ts('Cannot Delete')); + try { + CRM_Financial_BAO_FinancialType::deleteRecord(['id' => $this->_id]); + } + catch (CRM_Core_Exception $e) { + CRM_Core_Error::statusBounce($e->getMessage(), CRM_Utils_System::url('civicrm/admin/financial/financialType', "reset=1&action=browse"), ts('Cannot Delete')); } CRM_Core_Session::setStatus(ts('Selected financial type has been deleted.'), ts('Record Deleted'), 'success'); } -- 2.25.1