Skip to content

Commit

Permalink
Use getComponentPaymentFields from processorClass
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Nov 12, 2018
1 parent e2669e8 commit 1933e1a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions CRM/Core/BAO/Mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum
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) {
Expand Down
13 changes: 9 additions & 4 deletions CRM/Export/BAO/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ public static function exportComponents(
// 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;
}
Expand Down Expand Up @@ -1304,6 +1304,11 @@ public static function postalMailingFormat($exportTempTable, &$headerRows, &$sql

/**
* 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;
Expand Down Expand Up @@ -1345,8 +1350,8 @@ public static function setHeaderRows($field, $headerRows, $processor) {
// @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;
Expand Down Expand Up @@ -1817,7 +1822,7 @@ protected static function getTransformedFieldValue($field, $iterationDAO, $field
}
}
}
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(
Expand Down
4 changes: 3 additions & 1 deletion CRM/Export/BAO/ExportProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,11 @@ protected function hasRequestedComponentPaymentFields() {
/**
* 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'),
Expand Down

0 comments on commit 1933e1a

Please sign in to comment.