Problem/Motivation
FormBuilder::doBuildForm() resolves #process, #after_build, #submit, #validate, and #entity_builders callbacks through CallableResolver::getCallableFromDefinition(). This lets those callbacks use service notation with dependency injection, added in #3536726: Use CallableResolver for form callbacks.
#value_callback still resolves through plain is_callable() and call_user_func_array(). It cannot use service notation. This blocks converting existing static #value_callback methods into injectable service methods, including ManagedFile::valueCallback() and FileWidget::value(), needed by #3375423: Deprecate file_managed_file_save_upload(), file_save_upload() and _file_save_upload_from_form() and replace with a service and tracked under the meta issue #3221796: [META] Modernise file upload logic.
Steps to reproduce
Proposed resolution
Update the #value_callback handling in FormBuilder::doBuildForm() to call CallableResolver::getCallableFromDefinition(), matching the existing #process and #after_build handling. Existing static and array callables must keep working unchanged. Add a test covering a #value_callback defined in service notation.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3616645
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
kim.pepperComment #4
kim.pepperWe can probably just add to the existing change record for this issue https://www.drupal.org/node/3548821
Comment #5
kim.pepperBlocks #3616654: [PP-2] Convert ManagedFile::valueCallback() logic into an injectable service
Comment #6
nicxvan commentedWell that's unfortunate we missed that.
I haven't reviewed this yet, but we can't add this to the existing CR, this won't get in until 11.5 and that CR was for 11.3.
Comment #7
berdirNeeds work for the review and CR
Comment #8
kim.pepperAdded a CR and addressed review feedback.