switch to FALSE when no passed - seems clearer
authoreileenmcnaughton <eileen@fuzion.co.nz>
Mon, 29 Jun 2015 23:00:09 +0000 (23:00 +0000)
committereileenmcnaughton <eileen@fuzion.co.nz>
Mon, 29 Jun 2015 23:00:09 +0000 (23:00 +0000)
CRM/Financial/BAO/PaymentProcessor.php

index ba7e7fe6b651c199c03e1e26213071efcda68c5f..d8af267e8958635de7abf8828fc0d013a39b8808 100644 (file)
@@ -355,22 +355,24 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
    *   - LiveMode
    *   - FutureStartDate
    *
-   * @param array $ids
+   * @param array|bool $ids
    *
    * @return array
    *   available processors
    */
-  public static function getPaymentProcessors($capabilities = array(), $ids = array()) {
+  public static function getPaymentProcessors($capabilities = array(), $ids = FALSE) {
     $mode = NULL;
     $testProcessors = in_array('TestMode', $capabilities) ? self::getAllPaymentProcessors('test') : array();
     $processors = $liveProcessors = self::getAllPaymentProcessors('live');
 
     if (in_array('TestMode', $capabilities)) {
-      foreach ($testProcessors as $testProcessor) {
-        if (!in_array($testProcessor['id'], $ids)) {
-          foreach ($liveProcessors as $liveProcessor) {
-            if ($liveProcessor['name'] == $testProcessor['name']) {
-              $ids[] = $testProcessor['id'];
+      if ($ids) {
+        foreach ($testProcessors as $testProcessor) {
+          if (!in_array($testProcessor['id'], $ids)) {
+            foreach ($liveProcessors as $liveProcessor) {
+              if ($liveProcessor['name'] == $testProcessor['name']) {
+                $ids[] = $testProcessor['id'];
+              }
             }
           }
         }
@@ -379,7 +381,7 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
     }
 
     foreach ($processors as $index => $processor) {
-      if (!empty($ids) && !in_array($processor['id'], $ids)) {
+      if ($ids && !in_array($processor['id'], $ids)) {
         unset ($processors[$index]);
         continue;
       }