From 4a07230c01d208238395bec090e6508cb18493ed Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 3 Jun 2022 18:42:23 +1200 Subject: [PATCH] Add generic label get function - not used yet --- CRM/Import/Parser.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/CRM/Import/Parser.php b/CRM/Import/Parser.php index 1c2fe91fb0..5a08ade2f3 100644 --- a/CRM/Import/Parser.php +++ b/CRM/Import/Parser.php @@ -1608,6 +1608,30 @@ abstract class CRM_Import_Parser { return !empty($this->ambiguousOptions[$fieldName][mb_strtolower($importedValue)]); } + + /** + * Get the civicrm_mapping_field appropriate layout for the mapper input. + * + * For simple parsers (not contribution or contact) the input looks like + * ['first_name', 'custom_32'] + * and it is converted to + * + * ['name' => 'first_name', 'mapping_id' => 1, 'column_number' => 5], + * + * @param array $fieldMapping + * @param int $mappingID + * @param int $columnNumber + * + * @return array + */ + public function getMappingFieldFromMapperInput(array $fieldMapping, int $mappingID, int $columnNumber): array { + return [ + 'name' => $fieldMapping[0], + 'mapping_id' => $mappingID, + 'column_number' => $columnNumber, + ]; + } + /** * Get the field mappings for the import. * -- 2.25.1