From: eileen Date: Thu, 31 Dec 2020 20:18:26 +0000 (+1300) Subject: Rename PledgePayment create function X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=4cc3286d702a70b28e3e6d59b7cc4b27762ff4c6;p=civicrm-core.git Rename PledgePayment create function Plege payment has a non-standard create function. It is only called from one place in universe. This updates that 1 place to use a new name and puts in the create function in a more correct way. --- diff --git a/CRM/Pledge/BAO/Pledge.php b/CRM/Pledge/BAO/Pledge.php index 299e3ffa56..a63e854f15 100644 --- a/CRM/Pledge/BAO/Pledge.php +++ b/CRM/Pledge/BAO/Pledge.php @@ -197,7 +197,7 @@ class CRM_Pledge_BAO_Pledge extends CRM_Pledge_DAO_Pledge { foreach ($paymentKeys as $key) { $paymentParams[$key] = $params[$key] ?? NULL; } - CRM_Pledge_BAO_PledgePayment::create($paymentParams); + CRM_Pledge_BAO_PledgePayment::createMultiple($paymentParams); } $transaction->commit(); diff --git a/CRM/Pledge/BAO/PledgePayment.php b/CRM/Pledge/BAO/PledgePayment.php index d049f9e55a..a728c0b75e 100644 --- a/CRM/Pledge/BAO/PledgePayment.php +++ b/CRM/Pledge/BAO/PledgePayment.php @@ -76,11 +76,13 @@ WHERE pledge_id = %1 } /** + * Create pledge payments. + * * @param array $params * - * @return pledge + * @return CRM_Pledge_DAO_PledgePayment */ - public static function create($params) { + public static function createMultiple(array $params) { $transaction = new CRM_Core_Transaction(); $overdueStatusID = CRM_Core_PseudoConstant::getKey('CRM_Pledge_BAO_PledgePayment', 'status_id', 'Overdue'); $pendingStatusId = CRM_Core_PseudoConstant::getKey('CRM_Pledge_BAO_PledgePayment', 'status_id', 'Pending'); @@ -145,15 +147,14 @@ WHERE pledge_id = %1 } /** - * Add pledge payment. + * Create individual pledge payment. * * @param array $params - * Associate array of field. * * @return CRM_Pledge_DAO_PledgePayment - * pledge payment id + * @throws \CRM_Core_Exception */ - public static function add($params) { + public static function create(array $params): CRM_Pledge_DAO_PledgePayment { // set currency for CRM-1496 if (empty($params['id']) && !isset($params['currency'])) { $params['currency'] = CRM_Core_Config::singleton()->defaultCurrency; @@ -161,6 +162,21 @@ WHERE pledge_id = %1 return self::writeRecord($params); } + /** + * Add pledge payment. + * + * @deprecated - use the api which will use create (soon). + * + * @param array $params + * Fields in line with the database entity. + * + * @return CRM_Pledge_DAO_PledgePayment + * @throws \CRM_Core_Exception + */ + public static function add(array $params): CRM_Pledge_DAO_PledgePayment { + return self::create($params); + } + /** * Retrieve DB object based on input parameters. *