Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] [Import] Minor simplification #23464

Merged
merged 1 commit into from
May 17, 2022

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented May 14, 2022

Overview

[REF] [Import] Minor simplification

Before

More code

After

Less code

Technical Details

At this stage value already holds the phone_type_id, location_type_id, im_provider_id, website_type_id
if any, so we don't need to throw it away & start again.

The main thing this clarifies is that if website_type_id is set at this point the field will be 'url' and we don't need to check for that - obviously there may have been some past ambiguity but we now load the code from the civicrm_mapping_field table & on checking the 2 go together

Comments

There is still more simplification here to do - some of it still confuses me even thought it seems like a simple function.

However, my feeling is that in the end the function would ALSO map option values to ids & reformat dates, leaving less work for the validation function

At this stage value already holds the phone_type_id, location_type_id, im_provider_id, website_type_id
if any, so we don't need to throw it away & start again.
@civibot
Copy link

civibot bot commented May 14, 2022

(Standard links)

@civibot civibot bot added the master label May 14, 2022
@@ -2345,8 +2345,6 @@ private function getParams(array $values): array {
$relatedContactType = $this->getRelatedContactType($mappedField['relationship_type_id'], $mappedField['relationship_direction']);
$relatedContactLocationTypeID = $relatedContactKey ? $mappedField['location_type_id'] : NULL;
$relatedContactWebsiteTypeID = $relatedContactKey ? $mappedField['website_type_id'] : NULL;
$relatedContactIMProviderID = $relatedContactKey ? $mappedField['provider_id'] : NULL;
$relatedContactPhoneTypeID = $relatedContactKey ? $mappedField['phone_type_id'] : NULL;

$locationFields = ['location_type_id', 'phone_type_id', 'provider_id', 'website_type_id'];
$value = array_filter(array_intersect_key($mappedField, array_fill_keys($locationFields, 1)));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here is where $value is formed

@colemanw
Copy link
Member

Makes sense

@colemanw colemanw merged commit a4f37d9 into civicrm:master May 17, 2022
@colemanw colemanw deleted the import_on_dup branch May 17, 2022 02:56
@eileenmcnaughton
Copy link
Contributor Author

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants