From 0e32ed68b5dc3caa91c53798c9e7ff6843662e22 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 12 Nov 2018 14:04:42 +1300 Subject: [PATCH] Use getComponentPaymentFields from processorClass --- CRM/Core/BAO/Mapping.php | 1 + CRM/Export/BAO/Export.php | 13 +++++++++---- CRM/Export/BAO/ExportProcessor.php | 4 +++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CRM/Core/BAO/Mapping.php b/CRM/Core/BAO/Mapping.php index 3e8b324a36..29ea4dcf5f 100644 --- a/CRM/Core/BAO/Mapping.php +++ b/CRM/Core/BAO/Mapping.php @@ -440,6 +440,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { if (CRM_Core_Permission::access('CiviEvent')) { $fields['Participant'] = CRM_Event_BAO_Participant::exportableFields(); //get the component payment fields + // @todo - review this - inconsistent with other entities & hacky. if ($exportMode == CRM_Export_Form_Select::EVENT_EXPORT) { $componentPaymentFields = array(); foreach (CRM_Export_BAO_Export::componentPaymentFields() as $payField => $payTitle) { diff --git a/CRM/Export/BAO/Export.php b/CRM/Export/BAO/Export.php index c5e82945f7..57a53f7fbe 100644 --- a/CRM/Export/BAO/Export.php +++ b/CRM/Export/BAO/Export.php @@ -439,7 +439,7 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c // If we haven't selected specific payment fields, load in all the // payment headers. if (!$processor->isExportSpecifiedPaymentFields()) { - $paymentHeaders = self::componentPaymentFields(); + $paymentHeaders = $processor->getcomponentPaymentFields(); if (!empty($paymentDetails)) { $addPaymentHeader = TRUE; } @@ -1304,6 +1304,11 @@ WHERE {$whereClause}"; /** * Build componentPayment fields. + * + * This is no longer used by export but BAO_Mapping still calls it & we + * should find a generic way to handle this or move this to that class. + * + * @deprecated */ public static function componentPaymentFields() { static $componentPaymentFields; @@ -1345,8 +1350,8 @@ WHERE {$whereClause}"; // @todo - set this correctly in the xml rather than here. $headerRows[] = ts('IM Service Provider'); } - elseif ($processor->isExportPaymentFields() && array_key_exists($field, self::componentPaymentFields())) { - $headerRows[] = CRM_Utils_Array::value($field, self::componentPaymentFields()); + elseif ($processor->isExportPaymentFields() && array_key_exists($field, $processor->getcomponentPaymentFields())) { + $headerRows[] = CRM_Utils_Array::value($field, $processor->getcomponentPaymentFields()); } else { $headerRows[] = $field; @@ -1807,7 +1812,7 @@ WHERE {$whereClause}"; } } } - elseif ($processor->isExportSpecifiedPaymentFields() && array_key_exists($field, self::componentPaymentFields())) { + elseif ($processor->isExportSpecifiedPaymentFields() && array_key_exists($field, $processor->getcomponentPaymentFields())) { $paymentTableId = $processor->getPaymentTableID(); $paymentData = CRM_Utils_Array::value($iterationDAO->$paymentTableId, $paymentDetails); $payFieldMapper = array( diff --git a/CRM/Export/BAO/ExportProcessor.php b/CRM/Export/BAO/ExportProcessor.php index 0b77a52eda..2cf81b34db 100644 --- a/CRM/Export/BAO/ExportProcessor.php +++ b/CRM/Export/BAO/ExportProcessor.php @@ -519,9 +519,11 @@ class CRM_Export_BAO_ExportProcessor { /** * Get fields that indicate payment fields have been requested for a component. * + * Ideally this should be protected but making it temporarily public helps refactoring.. + * * @return array */ - protected function getComponentPaymentFields() { + public function getComponentPaymentFields() { return [ 'componentPaymentField_total_amount' => ts('Total Amount'), 'componentPaymentField_contribution_status' => ts('Contribution Status'), -- 2.25.1