Skip to content

Commit

Permalink
[REF] [Import] Minor simplification
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
eileenmcnaughton committed May 14, 2022
1 parent d04c1b1 commit fa41c52
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions CRM/Contact/Import/Parser/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down Expand Up @@ -2381,27 +2379,12 @@ private function getParams(array $values): array {
) {
$params[$relatedContactKey][$relatedContactFieldName] = [];
}
$value = [
$relatedContactFieldName => $importedValue,
'location_type_id' => $relatedContactLocationTypeID,
];

if (isset($relatedContactPhoneTypeID)) {
$value['phone_type_id'] = $relatedContactPhoneTypeID;
}

// get IM service Provider type id for related contact
if (isset($relatedContactIMProviderID)) {
$value['provider_id'] = $relatedContactIMProviderID;
}

$value[$relatedContactFieldName] = $importedValue;
$params[$relatedContactKey][$relatedContactFieldName][] = $value;
}
elseif (isset($relatedContactWebsiteTypeID)) {
$params[$relatedContactKey][$relatedContactFieldName][] = [
'url' => $importedValue,
'website_type_id' => $relatedContactWebsiteTypeID,
];
$value[$relatedContactFieldName] = $importedValue;
$params[$relatedContactKey][$relatedContactFieldName][] = $value;
}
elseif (empty($importedValue) && isset($relatedContactLocationTypeID)) {
if (empty($params[$relatedContactKey][$relatedContactFieldName])) {
Expand Down

0 comments on commit fa41c52

Please sign in to comment.