Refactored out of CRM_Core_PseudoConstant: billingMode(). CRM-12464
authorAllen Shaw <allen@emphanos.com>
Sat, 4 May 2013 22:48:06 +0000 (15:48 -0700)
committerColeman Watts <coleman@civicrm.org>
Thu, 30 May 2013 05:14:04 +0000 (22:14 -0700)
----------------------------------------
* CRM-12464: Search improvements in 4.4
  http://issues.civicrm.org/jira/browse/CRM-12464

CRM/Core/Payment.php
CRM/Core/PseudoConstant.php
CRM/Financial/BAO/PaymentProcessorType.php

index 778adbaa42a36a943c8caeeeda8c2d87f0b05c03..80a7702f519ed419bed1234a062e290aabec3d26 100644 (file)
@@ -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',
+    );
+  }
 }
 
index bb8e4bf77489ae8156221cc5d7f490ec5668e0ce..82e834fd724075778935b8ccb9b1064352540504 100644 (file)
@@ -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
index 14e87df0b213cf10567cd3f06424173734393907..dd37d1f06fd3acea3c3b94d976d52abdb03417b7 100644 (file)
@@ -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");
       }
     }