Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Checklist elements are supposed to be build using the #callback
attribute in checklist definition, however it isn't possible to pass additional variables into the callback since there is a straight up call call_user_func($definition['#callback']);
.
Proposed resolution
Introduce a new attribute in the checklist definition #callback_arguments
and pass these arguments through to the callback.
Remaining tasks
N/A
User interface changes
N/A
API changes
New optional checklist definition property #callback_arguments
.
Data model changes
N/A
Release notes snippet
N/A
Comment | File | Size | Author |
---|---|---|---|
#3 | add_callback_argument-3077054-3.patch | 2.18 KB | Erik Frèrejean |
Comments
Comment #2
Erik FrèrejeanAttached a patch and added a change record: https://www.drupal.org/node/3077055
Comment #3
Erik FrèrejeanMade a typo in the api file.
Comment #4
TravisCarden CreditAttribution: TravisCarden at Acquia commentedThank you for the contribution, @Erik Frèrejean. Can you help me understand the motivation for this change? What are you unable to do today that it would enable you to do?
Comment #5
Erik FrèrejeanSure. First of all the change doesn't allow me to do anything I can't do without the patch, but in order to do so I need to rely on deprecated behavior, which for obvious reasons don't want to do ;).
Basically we've build a UI for the checklist api where certain users can create checklists on the fly by connecting a couple of custom entity types. In essence the implementation of
hook_checklistapi_checklist_info
look like:Our initial implementation has the loop defined in
_buildlistitems
straight in the info hook, but per the api documentation that behavior is deprecated. And since the content of the list is defined by the entity that is being converted it is needed to pass the entity through to the callback.Comment #7
TravisCarden CreditAttribution: TravisCarden as a volunteer commentedThat makes sense, @Erik Frèrejean. Committed. Thanks!
Comment #8
TravisCarden CreditAttribution: TravisCarden as a volunteer commentedOops. Meant to mark fixed, not postponed.