Problem/Motivation
#3356894: Make field selection less overwhelming by introducing groups Added hook_field_type_category_info to allow modules to define metadata about field type categories.
In doing so, we are putting the onus on modules implementing this hook to also implement a preprocess hook if they need libraries attached to theme an icon
Steps to reproduce
Eg. datetime_range_preprocess_form_element__new_storage_type
Proposed resolution
Allow the info definition to nominate libraries (like we do for layout plugins).
Automatically attach the libraries to the form on their behalf so they don't need to implement two hooks
Remove any such hooks (e.g. datetime range, comment, file, link, media, options, telephone, text)
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3372092
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:
- 3372092-allow-fieldtypecategories.yml-entries
changes, plain diff MR !4463
Comments
Comment #2
larowlanComment #3
larowlanComment #4
lauriii+1. Let's get #3372097: Consider replacing hook_field_type_category_info with YML based plugin discovery done first. 👍
Comment #5
lauriiiNow that #3372097: Consider replacing hook_field_type_category_info with YML based plugin discovery has been committed, this is unblocked.
Comment #6
catchComment #8
tim.plunkettComment #10
lauriiiComment #11
larowlanLeft a review
Comment #12
lauriiiBack to NR
Comment #13
larowlanWasn't as big a cleanup as I hoped, but still seems cleaner. Thanks!
Comment #14
srishtiiee commentedComment #15
tim.plunkettThere are still 5 modules using the preprocess hook to add in icon libraries.
Comment #16
tim.plunkett@srishtiiee points out that these 5 are in the General category. My suggestion was to switch from a preprocess hook to hook_library_info_alter implementations, with each adding their own icons to a General category library.
Comment #17
lauriiiI remember I tried to implement this first using
hook_library_info_alterbut that might be tricky unless we get rid of the library definition and try to inject the assets directly to the library (which seems more hacky than the current solution). The problem is that the library we're adding depends on the existing library, and we want to load the existing assets before the new assets. If we wanted vice versa, it would be simple because we could just make the existing library depend on the new library.Comment #18
srishtiiee commentedComment #19
smustgrave commentedThink with a change like this a CR will be needed.
Comment #20
kim.pepperI think we are ok because this updates a feature that has only been added in 11.x and never been released?
Comment #21
smustgrave commentedBut what if someone used this new feature as a patch? Not sure if that counts though.
Comment #22
tim.plunkettThis is an API addition to an unreleased feature, I agree it doesn't need a CR
Comment #23
tim.plunkettComment #24
lauriiiComment #25
srishtiiee commentedComment #26
kunal.sachdev commentedLooking great 👍. Needs work for two small nits.
Comment #27
srishtiiee commentedComment #28
kunal.sachdev commentedComment #29
lauriiiPosted one comment on the MR
Comment #30
lauriiiThis needs a rebase now that #3371301: Retrieve field type category information in \Drupal\Core\Field\FieldTypePluginManager::getGroupedDefinitions has landed.
Comment #31
srishtiiee commentedComment #32
wim leersReviewed :)
Comment #33
srishtiiee commentedAddressed the review feedback.
Comment #34
wim leers🏓 Almost ready!
Comment #35
srishtiiee commentedComment #36
kunal.sachdev commentedConfirmed that there is no need for modules to implement preprocess hook for attaching asset libraries and all such hooks are removed.
Comment #38
lauriiiCommitted d418da3 and pushed to 11.x. Thanks!
Comment #40
wim leersLooks great! 👍