From 92414c615997a50d1cff628d1e6427ef7da98316 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 20 May 2022 15:39:43 +1200 Subject: [PATCH] [REF] Move list of fields that have been upgraded --- CRM/Contact/Import/Parser/Contact.php | 14 ++++++++++++++ CRM/Import/Parser.php | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/CRM/Contact/Import/Parser/Contact.php b/CRM/Contact/Import/Parser/Contact.php index 67047e78128d..5e112df6bf01 100644 --- a/CRM/Contact/Import/Parser/Contact.php +++ b/CRM/Contact/Import/Parser/Contact.php @@ -81,6 +81,20 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { protected $fieldMetadata = []; + /** + * Fields which are being handled by metadata formatting & validation functions. + * + * This is intended as a temporary parameter as we phase in metadata handling. + * + * The end result is that all fields will be & this will go but for now it is + * opt in. + * + * @var array + */ + protected $metadataHandledFields = [ + 'gender_id', + ]; + /** * Relationship labels. * diff --git a/CRM/Import/Parser.php b/CRM/Import/Parser.php index 5ccaf9858bf7..43cd7dd9386a 100644 --- a/CRM/Import/Parser.php +++ b/CRM/Import/Parser.php @@ -53,6 +53,18 @@ abstract class CRM_Import_Parser { */ protected $userJobID; + /** + * Fields which are being handled by metadata formatting & validation functions. + * + * This is intended as a temporary parameter as we phase in metadata handling. + * + * The end result is that all fields will be & this will go but for now it is + * opt in. + * + * @var array + */ + protected $metadataHandledFields = []; + /** * @return int|null */ @@ -1186,8 +1198,8 @@ protected function validateRequiredFields(array $requiredFields, array $params, * @throws \API_Exception */ protected function getTransformedFieldValue(string $fieldName, $importedValue) { - // For now only do gender_id as we need to work through removing duplicate handling - if ($fieldName !== 'gender_id' || empty($importedValue)) { + // For now only do gender_id etc as we need to work through removing duplicate handling + if (empty($importedValue) || !in_array($fieldName, $this->metadataHandledFields, TRUE)) { return $importedValue; } return $this->getFieldOptions($fieldName)[$importedValue] ?? 'invalid_import_value';