CRM-19815 minor tidy ups, reduce switch clause,remove unused var
authoreileen <emcnaughton@wikimedia.org>
Mon, 9 Jan 2017 00:20:08 +0000 (13:20 +1300)
committereileen <emcnaughton@wikimedia.org>
Tue, 7 Feb 2017 04:00:13 +0000 (17:00 +1300)
CRM/Contribute/BAO/Query.php

index f0ca0f718646a09a49ad8e9fa01f9250cb84ed53..f7e4f5d06c8bde41517f1ce6407e1ef42139d490 100644 (file)
@@ -196,7 +196,17 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
         return;
       }
     }
-
+    // These are legacy names.
+    // @todo enotices when these are hit so we can start to elimnate them.
+    $fieldAliases = array(
+      'financial_type' => 'financial_type_id',
+      'contribution_page' => 'contribution_page_id',
+      'payment_instrument' => 'payment_instrument_id',
+      // or payment_instrument_id?
+      'contribution_payment_instrument' => 'contribution_payment_instrument_id',
+      'contribution_status' => 'contribution_status_id',
+    );
+    $name = isset($fieldAliases[$name]) ? $fieldAliases[$name] : $name;
     $qillName = $name;
     $pseudoExtraParam = array();
 
@@ -249,12 +259,6 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
         $query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1;
         return;
 
-      case 'financial_type':
-      case 'contribution_page':
-      case 'payment_instrument':
-      case 'contribution_payment_instrument':
-      case 'contribution_status':
-        $name .= '_id';
       case 'financial_type_id':
         // @todo we need to make this resemble a hook approach.
         CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes);