-
-
Notifications
You must be signed in to change notification settings - Fork 824
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] move metadata calculations to a trait #15018
Conversation
(Standard links)
|
dae8945
to
8812cc7
Compare
8812cc7
to
b80853f
Compare
@seamuslee001 I've updated this to be much closer to a straight extraction for easier review - I've kept the helper functions but removed the calls to them for now |
This metadata needs to be shared between multiple import forms. They do not have a common parent. Curently this is done via calculating once & passing via quickform. However, the formats are convoluted & hard to read. Information that is user generated should be calculated per form - not so much metadata
b80853f
to
91b4c63
Compare
//CRM-5125 | ||
//supporting import for contact subtypes | ||
$csType = NULL; | ||
if ($this->getContactSubType()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added functions to avoid enotices here
$csType = NULL; | ||
if ($this->getContactSubType()) { | ||
//custom fields for sub type | ||
$subTypeFields = CRM_Core_BAO_CustomField::getFieldsForImport($this->getContactSubType()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
* | ||
* @return array | ||
*/ | ||
protected function getRelationships(): array { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this is just a subset that is also useful elsewhere as it's own fn
thanks @seamuslee001 this unblocks me on writing tests for the bug I'm chasing down |
Overview
Refactor to increase shared code
Before
Metadata passed around
After
Metadata retrieved from shared trait
Technical Details
A lot of the complexity of the import classes comes from complex & convoluted handling of metadata.
For reasons now obsolete the metadata is loaded & wrangled into various arrays on the first form and
then passed through storing the form in the session object to later forms (which don't have a shared parent).
We should be passing user form input around but not metadata as that can be retrieved as needed (and
cached for performance). This moves couple of functions out to the metadata and adds a couple of calls to them
reviewer preference
Comments