Add ContainerFactoryPluginInterface to Drupal\Core\Field\WidgetBase and Drupal\Core\Field\FormatterBase

Created on 30 April 2019, over 5 years ago
Updated 14 September 2023, over 1 year ago

Problem/Motivation

After visiting @alexpott's session "Drupal 9 is coming: Getting your code ready
" (https://events.drupal.org/seattle2019/sessions/drupal-9-coming-getting-y...) in Seattle, I wanted to make the contrib select2 module more BC stable by preventing constructor overwrites.

I found out that I am not able to prevent constructor overwriting for the Select2EntityReferenceWidget (https://git.drupalcode.org/project/select2/blob/8.x-1.x/src/Plugin/Field...) because none of it's base classes is implementing the ContainerFactoryPluginInterface.
The base class chain of this class is Select2EntityReferenceWidget -> Select2Widget -> OptionsSelectWidget -> OptionsWidgetBase -> WidgetBase. That means if one of this base classes changes it's constructor, I will have a breakage in Select2EntityReferenceWidget.

Proposed resolution

Add ContainerFactoryPluginInterface to Drupal\Core\Field\WidgetBase and Drupal\Core\Field\FormatterBase and implement the ::create() method in them. The big advantage is that all child classes will be more BC stable.

Remaining tasks

Discuss
Implement
Test
Commit

User interface changes

n.a.

API changes

Add ContainerFactoryPluginInterface to Drupal\Core\Field\WidgetBase

Data model changes

n.a.

Release notes snippet

n.a.

πŸ“Œ Task
Status

Fixed

Version

8.8 ⚰️

Component
FieldΒ  β†’

Last updated 2 days ago

Created by

πŸ‡©πŸ‡ͺGermany chr.fritsch πŸ‡©πŸ‡ͺπŸ‡ͺπŸ‡ΊπŸŒ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024