Skip to content

Commit

Permalink
Merge pull request #23363 from eileenmcnaughton/import_var
Browse files Browse the repository at this point in the history
[REF] [Import] Trivial - simplify variables
  • Loading branch information
eileenmcnaughton authored May 5, 2022
2 parents 79667be + d674bf1 commit 266f005
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions CRM/Contact/Import/Parser/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -2931,6 +2931,10 @@ public function &getActiveFieldParams() {
}
$relatedContactFieldName = $this->_activeFields[$i]->_relatedContactDetails;
$relatedContactType = $this->_activeFields[$i]->_relatedContactType;
$relatedContactLocationTypeID = $this->_activeFields[$i]->_relatedContactLocType;
$relatedContactWebsiteTypeID = $this->_activeFields[$i]->_relatedContactWebsiteType ?? NULL;
$relatedContactIMProviderID = $this->_activeFields[$i]->_relatedContactImProvider ?? NULL;
$relatedContactPhoneTypeID = $this->_activeFields[$i]->_relatedContactPhoneType ?? NULL;

if (isset($this->_activeFields[$i]->_value)) {
if (isset($this->_activeFields[$i]->_hasLocationType)) {
Expand Down Expand Up @@ -2979,35 +2983,35 @@ public function &getActiveFieldParams() {
$params[$this->_activeFields[$i]->_related]['contact_type'] = $relatedContactType;
}

if (isset($this->_activeFields[$i]->_relatedContactLocType) && !empty($this->_activeFields[$i]->_value)) {
if (isset($relatedContactLocationTypeID) && !empty($this->_activeFields[$i]->_value)) {
if (!empty($params[$this->_activeFields[$i]->_related][$relatedContactFieldName]) &&
!is_array($params[$this->_activeFields[$i]->_related][$relatedContactFieldName])
) {
$params[$this->_activeFields[$i]->_related][$relatedContactFieldName] = [];
}
$value = [
$relatedContactFieldName => $this->_activeFields[$i]->_value,
'location_type_id' => $this->_activeFields[$i]->_relatedContactLocType,
'location_type_id' => $relatedContactLocationTypeID,
];

if (isset($this->_activeFields[$i]->_relatedContactPhoneType)) {
$value['phone_type_id'] = $this->_activeFields[$i]->_relatedContactPhoneType;
if (isset($relatedContactPhoneTypeID)) {
$value['phone_type_id'] = $relatedContactPhoneTypeID;
}

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

$params[$this->_activeFields[$i]->_related][$relatedContactFieldName][] = $value;
}
elseif (isset($this->_activeFields[$i]->_relatedContactWebsiteType)) {
elseif (isset($relatedContactWebsiteTypeID)) {
$params[$this->_activeFields[$i]->_related][$relatedContactFieldName][] = [
'url' => $this->_activeFields[$i]->_value,
'website_type_id' => $this->_activeFields[$i]->_relatedContactWebsiteType,
'website_type_id' => $relatedContactWebsiteTypeID,
];
}
elseif (empty($this->_activeFields[$i]->_value) && isset($this->_activeFields[$i]->_relatedContactLocType)) {
elseif (empty($this->_activeFields[$i]->_value) && isset($relatedContactLocationTypeID)) {
if (empty($params[$this->_activeFields[$i]->_related][$relatedContactFieldName])) {
$params[$this->_activeFields[$i]->_related][$relatedContactFieldName] = [];
}
Expand Down

0 comments on commit 266f005

Please sign in to comment.