-
-
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
Use new lookup trait to eliminate use of undefined properties userDisplayName
#27259
Conversation
🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷 Introduction for new contributors...
Quick links for reviewers...
|
Hmm it switched to actual display name - not first/ last for the name in the email 'to' I think that is good, not bad....
|
b701cba
to
88eff0e
Compare
@eileenmcnaughton I think the overcomplicatedness of these forms lies in the way they store and pass around entity ids as well as entity values.
I think the reason this PR struggles to make use of the lookup trait is because #27258 entrenches further into the status quo by adding contact id getters/setters and then this PR tries to adapt the lookup trait retroactively on top of those getter/setters. But if you mentally shift to the new model, LookupTrait is quite elegant. You don't need to make a new getter/setter for contact_id because |
@colemanw yeah - but then you need to call the 'define' in multiple places & check before doing so whether is already defined before doing so because flow-dependent it might or might not be. The relevant ids (contact ID is one, others are event ID, participant ID, contribution ID price set ID and discount ID) are available at different points in time in different flows. |
@eileenmcnaughton if it would help, I could push up another patch to make |
@colemanw possibly - but would that make it more error prone too? Although I could make a case that double calling define would add to any existing - eg. I've just saved a value & I want to update (or create) the defined entity. The issue isn't just double calling define - it's know knowing if the entity is defined at the point in the flow you are at. We can get the various IDs from multiple places depending on the flow - the use of |
@colemanw I tried to use the new trait in a different scenario #27273 & in that case it would have been usable with the addition of support for
That scenario differs from this in that there is just one path through the code & the relevant entities either can be defined at that point or they don't exist |
…playName and contributorDisplayName
88eff0e
to
0aaf9af
Compare
@colemanw that makes this look a bit nicer.... |
@eileenmcnaughton agreed. |
Ok - it's been merge ready a couple of days - let's merge |
Overview
Use new lookup trait to eliminate use of undefined properties
userDisplayName
Before
Property
_userDisplayName
referenced in multiple places but not defined. The only place where it is reference from a function other than where it is determined is in the Paricipant form preProcess. In addition the participant form also usescontributorDisplayName
to refer to the same value - this second variant is used to set the message to be displayed to the user at the end (only). It refers to the same contact (the ability to record a payment from a different contact is only available on the Membership forms, not events)After
Rather than define these 2 properties there are 2 approaches
getContactValue()
to get the variables when needed in thesetStatus
andpreProcess
functionsTechnical Details
@colemanw I am using the new
lookup
function here - but I wound up wrapping in it a function - https://github.com/civicrm/civicrm-core/compare/master...eileenmcnaughton:civicrm-core:lookup?expand=1#diff-a1c8943f991b49e1c885133fad3edc222523542e1ce97b89d7fbba222197000fR576-R588 becausea) the goal is to be able to call the function anywhere on the form and if the contact is not yet defined it should return NULL - hence it can be used for things like
b) the contact ID becomes available at different points in different flows. If a contact ID (cid) is in the url or an ID is in in the url it can be looked up in
preProcess
. However, it is not available untilpostProcess
otherwise. The goal is to be able to look up a value from any part of the form & get the same results.Note that this
getContactValue()
is on the one form at the moment. That form has pre-existinggetParticipantValue()
&getEventValue()
functions - all 3 of which would probably wind up in a FormTrait rather than the form once it is settledComments
Merging #27258 will simplify this