[REF] [Import] Minor code cleanup #23444
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
[REF] [Import] Minor code cleanup
Before
A
$value
array is constructed if the mapped field has a value for eitherlocation_type_id
orwebsite_type_id
. The array is a subset of the$mappedField
array holding the location values & in addition it has the field name & value - eg. it would look like$value = ['location_type_id' => 1, 'email' => 'e@mail.com'];
or
$value = ['website_type_id' => 1, 'url' => 'https://civicrm.org'];
The construction builds up the array with a whole lotta ifs
After
array foo used instead
Technical Details
This is how the code section winds up looking
Comments
Solid test cover of this function in
CRM_Contact_Import_Parser_ContactTest