Problem/Motivation
In the Drupal 8 cycle we removed most info hooks and replaced them with plugins.
In #3356894: Make field selection less overwhelming by introducing groups we added a new one hook_field_type_category_info
That issue represents a huge win for Drupal so we didn't want to slow progress debating whether it should be a hook or plugins.
This issue is to explore that further.
| Approach | Pros | Cons |
|---|---|---|
| Info hook |
|
|
| Plugins (yml) |
|
|
Steps to reproduce
Proposed resolution
See what the code looks like using YML discovery with an alter hook.
Add a default plugin implementation and change some of the logic in FieldStorageAddForm to it (e.g ->getWeight, ->getDescription, ->isDefault)
Consider bundling in #3372092: Allow field_type_categories.yml entries to define asset libraries too
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3372097
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 #2
larowlanComment #3
lauriiiConverting to plugins would make implementing DX improvements like #3372092: Allow field_type_categories.yml entries to define asset libraries easier too.
Comment #6
srishtiiee commentedComment #7
smustgrave commentedSome unresolved threads.
Comment #8
srishtiiee commentedComment #9
tedbowLooking good. Glad we are doing this!
we also need a test for the new plugin manager
Comment #10
srishtiiee commentedComment #11
larowlanLeft a review, also updated issue credits
Comment #12
srishtiiee commentedComment #13
larowlanThis looks good to go.
Adding tag for the followup to change $val to something else per review from @tedbow
Adding 'needs change record updates' to repurpose the one about the info hook to be about the new plugin-type
Comment #14
lauriiiComment #15
longwaveSome BC considerations and a bikeshed comment about the naming of this whole thing.
Comment #16
longwaveComment #17
srishtiiee commentedComment #18
lauriiiConfirmed that the feedback has been addressed 👍 I also postponed #3371301: Retrieve field type category information in \Drupal\Core\Field\FieldTypePluginManager::getGroupedDefinitions on this.
Comment #19
lauriiiFiled the follow-up issue: #3375816: Rename $val in \Drupal\field_ui\Form\FieldStorageAddForm::buildForm to something more descriptive.
Comment #20
longwaveOne more naming nitpick: plugin managers are singular, e.g.
plugin.manager.blockorplugin.manager.actionand also field plugin managers have a common namespace:plugin.manager.field.field_typeplugin.manager.field.widgetplugin.manager.field.formatterTherefore I think the service name for this should be
plugin.manager.field.field_type_categoryWe also should add an interface for this:
We should typehint this interface in the FieldTypePluginManager constructor and docblock (instead of the generic PluginManagerInterface), and then also should add an interface alias so this service can be autowired:
Also it would be good if the new service was immediately after
plugin.manager.field.field_typeincore.services.ymlas we try to group similar services together.Comment #21
srishtiiee commentedComment #22
lauriiiConfirmed that #20 has been addressed! Thanks for the reviews @longwave and thank you for addressing all the feedback @srishtiiee! 😊
Comment #23
longwaveCommitted and pushed f1a52222a7 to 11.x. Thanks!
Will publish the change records.