Skip to content

Commit

Permalink
Merge pull request #23518 from eileenmcnaughton/import_meta
Browse files Browse the repository at this point in the history
[REF] Move list of fields that have been upgraded
  • Loading branch information
totten authored May 20, 2022
2 parents 0560b88 + 92414c6 commit 7b79a6f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
14 changes: 14 additions & 0 deletions CRM/Contact/Import/Parser/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
16 changes: 14 additions & 2 deletions CRM/Import/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit 7b79a6f

Please sign in to comment.