From d8ad616b45525620c297bcf67aec26802ced1261 Mon Sep 17 00:00:00 2001 From: Allen Shaw Date: Sat, 4 May 2013 15:48:06 -0700 Subject: [PATCH] Refactored out of CRM_Core_PseudoConstant: billingMode(). CRM-12464 ---------------------------------------- * CRM-12464: Search improvements in 4.4 http://issues.civicrm.org/jira/browse/CRM-12464 --- CRM/Core/Payment.php | 10 ++++++++ CRM/Core/PseudoConstant.php | 28 ++-------------------- CRM/Financial/BAO/PaymentProcessorType.php | 4 ++-- 3 files changed, 14 insertions(+), 28 deletions(-) diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php index 778adbaa42..80a7702f51 100644 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@ -379,5 +379,15 @@ INNER JOIN civicrm_contribution con ON ( con.contribution_recur_id = rec.id ) return $newCredit; } + /* Return a static array of available billing modes, in the format: + * $array[numeric key] = 'descriptive text'. + */ + static function getBillingModes() { + return array( + CRM_Core_Payment::BILLING_MODE_FORM => 'form', + CRM_Core_Payment::BILLING_MODE_BUTTON => 'button', + CRM_Core_Payment::BILLING_MODE_NOTIFY => 'notify', + ); + } } diff --git a/CRM/Core/PseudoConstant.php b/CRM/Core/PseudoConstant.php index bb8e4bf774..82e834fd72 100644 --- a/CRM/Core/PseudoConstant.php +++ b/CRM/Core/PseudoConstant.php @@ -65,13 +65,6 @@ class CRM_Core_PseudoConstant { */ private static $activityType; - /** - * payment processor billing modes - * @var array - * @static - */ - private static $billingMode; - /** * states, provinces * @var array @@ -542,25 +535,6 @@ class CRM_Core_PseudoConstant { } return self::$activityType[$index]; } - - /** - * Get all payment-processor billing modes - * - * @access public - * @static - * - * @return array ($id => $name) - */ - public static function billingMode() { - if (!self::$billingMode) { - self::$billingMode = array( - CRM_Core_Payment::BILLING_MODE_FORM => 'form', - CRM_Core_Payment::BILLING_MODE_BUTTON => 'button', - CRM_Core_Payment::BILLING_MODE_NOTIFY => 'notify', - ); - } - return self::$billingMode; - } /** * Get all the State/Province from database. @@ -852,6 +826,8 @@ WHERE id = %1"; } /** + * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object. + * * Get all permissioned groups from database * * The static array group is returned, and if it's diff --git a/CRM/Financial/BAO/PaymentProcessorType.php b/CRM/Financial/BAO/PaymentProcessorType.php index 14e87df0b2..dd37d1f06f 100644 --- a/CRM/Financial/BAO/PaymentProcessorType.php +++ b/CRM/Financial/BAO/PaymentProcessorType.php @@ -151,12 +151,12 @@ class CRM_Financial_BAO_PaymentProcessorType extends CRM_Financial_DAO_PaymentPr if (isset($paymentProcessorType->billing_mode)) { // ugh unidirectional manipulation if (!is_numeric($paymentProcessorType->billing_mode)) { - $billingModes = array_flip(CRM_Core_PseudoConstant::billingMode()); + $billingModes = array_flip(CRM_Core_Payment::getBillingModes()); if (array_key_exists($paymentProcessorType->billing_mode, $billingModes)) { $paymentProcessorType->billing_mode = $billingModes[$paymentProcessorType->billing_mode]; } } - if (!array_key_exists($paymentProcessorType->billing_mode, CRM_Core_PseudoConstant::billingMode())) { + if (!array_key_exists($paymentProcessorType->billing_mode, CRM_Core_Payment::getBillingModes())) { throw new Exception("Unrecognized billing_mode"); } } -- 2.25.1