Problem/Motivation
Sometimes (certainly in contrib, perhaps in core?) we come up with better widgets and formatters for various fields. Since we can't remove old widgets immediately, it'd be great to be able to deprecate them. There's a "no_ui" annotation for field type plugins, but not for widgets or formatters. It'd be great if you could mark a widget or formatter as deprecated, and then have it disappear from the UI unless it was actively in use for a given form/view mode config.
Proposed resolution
Add smarts about a @deprecated
annotation to field widget and formatter plugins.
Change the signature of \Drupal\field_ui\Form\EntityDisplayFormBase::getApplicablePluginOptions()
to pass along the current setting.
If a given plugin item was deprecated and not the current setting, remove it from the list.
Quoting @larowlan from Slack:
For BC reasons we could probably wrap that in another method so it became:
'#options' => $this->removeDeprecated($this->getApplicablePluginOptions($field_definition), $display_options),
but given it's a protected method, it would be more efficient to just change the signature.
Remaining tasks
- Agree on the approach.
- Implement it.
- Add tests.
- Reviews / refinements / sign-off.
- RTBC.
- Commit.
User interface changes
TBD. Ideally, deprecated field widget and formatter plugins will disappear from the UI unless they're currently in use.
API changes
TBD.
Data model changes
Release notes snippet
TBD.