-
-
Notifications
You must be signed in to change notification settings - Fork 825
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] towards cleanup of update membership code #13759
Conversation
(Standard links)
|
*/ | ||
protected static function getRelatedMemberships($contributionID) { | ||
$contribution = new CRM_Contribute_BAO_Contribution(); | ||
$contribution->id = $contributionID; |
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.
this 'double loading' of contribution is because we expect to stop passing the contribution object later
$memberships = $contribution->_relatedObjects['membership']; | ||
foreach ($memberships as $membershipTypeIdKey => $membership) { | ||
$memberships = self::getRelatedMemberships($contribution->id); | ||
foreach ($memberships as $membership) { | ||
if ($membership) { |
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.
this is is extraneous - but let's remove as a separate PR to keep this clean
b823275
to
f21d530
Compare
This PR limits itself to siphoning off how the memberships are fetched & having that function - return as an array of arrays rather than an array of objects - index the array by id rather than membership type This is a step towards the changes in civicrm#12542 & it should allow a separation of concerns relating to the LOADING of memberships from the processing. I note that the PR I'm looking at changes what gets loaded & that should be it's own PR but also that there is an extraneous if() here - I didn't alter that because it is a big white space change & doing on it's own will make that easy to review
Thanks @eileenmcnaughton. Tested locally and this works. It also has good test coverage which is passing - eg.
Ok to merge |
@mattwire I'll bang up a follow up that removes the redundant IF |
Overview
Minor code cleanup towards #12542
Before
less readable
After
More readable
Technical Details
@mattwire I've pulled this out as I think breaking out the loading of the memberships would simplify changing that function
This PR limits itself to siphoning off how the memberships are fetched & having that function
This is a step towards the changes in #12542
& it should allow a separation of concerns relating to the LOADING of memberships from the
processing.
I note that the PR I'm looking at changes what gets loaded & that should be it's own PR
but also that there is an extraneous if() here - I didn't alter that because
it is a big white space change & doing on it's own will make that easy to review
Comments
Anything else you would like the reviewer to note