-
-
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] Move repeated code for Price Field labels into separate function #26375
[REF] Move repeated code for Price Field labels into separate function #26375
Conversation
(Standard links)
|
CRM/Price/BAO/PriceField.php
Outdated
$count = CRM_Utils_Array::value('count', $opt, ''); | ||
$max_value = CRM_Utils_Array::value('max_value', $opt, ''); |
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.
Not a blocker but it would be really cool if you got rid of the deprecated CRM_Utils_Array::value
calls while you're in here. That function is always a bit ambiguous but I'm guessing this is what it's trying to do:
$count = CRM_Utils_Array::value('count', $opt, ''); | |
$max_value = CRM_Utils_Array::value('max_value', $opt, ''); | |
$count = $opt['count'] ?? ''; | |
$max_value = $opt['max_value' ?? ''; |
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.
For sure! (I did this one before I learned about getting rid of those).
ba1ab6a
to
724372c
Compare
Oh wow - good detective work - I had never spotted those parts of the case-from-hell were copy & paste |
724372c
to
3785632
Compare
Code looks good to me. Anyone able to |
Thanks @eileenmcnaughton and @colemanw. Here's the next refactor step for this. |
Found a regression with Select fields: https://lab.civicrm.org/dev/core/-/issues/4439 |
Overview
This is a first step towards some other improvements, but all this PR does is make this code more maintainable by moving a lot of repeated copy-pasted text into a separate function.
The code was not entirely identical in some places (for instance, before the pre and post help for selects had no spans around them, now they do, sold out markings missing on select options, now present), but I think these were oversights that were changed in one place and not in others. There is no significant functional change.
Comments
Lines 294-297 are now redundant for all cases except text fields. They'll be removed in the following PR but need to stay for now so that text fields keep working.