From c8adad81defa344aad8b7bf81f18b99cd86364a7 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 27 Jul 2018 01:48:53 +1200 Subject: [PATCH] Extract getMungedFieldName --- CRM/Export/BAO/Export.php | 7 +------ CRM/Export/BAO/ExportProcessor.php | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/CRM/Export/BAO/Export.php b/CRM/Export/BAO/Export.php index dc000248d7..f2f1793ce7 100644 --- a/CRM/Export/BAO/Export.php +++ b/CRM/Export/BAO/Export.php @@ -796,12 +796,7 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c return; } - $fieldName = CRM_Utils_String::munge(strtolower($field), '_', 64); - if ($fieldName == 'id') { - $fieldName = 'civicrm_primary_id'; - } - - $sqlColumns[$fieldName] = $processor->getSqlColumnDefinition($field, $fieldName); + $sqlColumns[$processor->getMungedFieldName($field)] = $processor->getSqlColumnDefinition($field); } /** diff --git a/CRM/Export/BAO/ExportProcessor.php b/CRM/Export/BAO/ExportProcessor.php index deea2d9e81..49f24e636c 100644 --- a/CRM/Export/BAO/ExportProcessor.php +++ b/CRM/Export/BAO/ExportProcessor.php @@ -438,12 +438,14 @@ class CRM_Export_BAO_ExportProcessor { } /** + * Get the sql column definition for the given field. + * * @param $field - * @param $fieldName * * @return mixed */ - public function getSqlColumnDefinition($field, $fieldName) { + public function getSqlColumnDefinition($field) { + $fieldName = $this->getMungedFieldName($field); // early exit for master_id, CRM-12100 // in the DB it is an ID, but in the export, we retrive the display_name of the master record @@ -545,4 +547,18 @@ class CRM_Export_BAO_ExportProcessor { } } + /** + * Get the munged field name. + * + * @param string $field + * @return string + */ + public function getMungedFieldName($field) { + $fieldName = CRM_Utils_String::munge(strtolower($field), '_', 64); + if ($fieldName == 'id') { + $fieldName = 'civicrm_primary_id'; + } + return $fieldName; + } + } -- 2.25.1