[Import] [Ref] Iterate through the mapping of fields #23384
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
[Import] [Ref] Iterate through the mapping of fields
Before
The process for mapping fields is crazy complex.....
The form layer has to take the submitted value for 'mapper' and split it into 8 arrays ie
These arrays are passed to the field constructer and tinkered with a bit in
init
before being accessed ingetActiveFieldMapping
to determine how the row of values maps to a$params
arrayAfter
We already have a function that interprets what the
mapper
means into the format we use incivicrm_field_mapping
so use that function to interpret rather than array-o-rama. The only thing we need to change is to interpret 'email with no location type' to 'email with location_type of "Primary" - everything else is already done in this functionTechnical Details
The change involves updating tests to pass in the
mapper
- rather than doing weird contortions to imitate the forms.We have good test cover - including a test specifically merged in preparation for this (
testMapFields
)Comments
With this change most of the
construct
function &init
is obsolete as well as a lot of code on the form layer - I've left that cleanup as a follow up for legibility