Convert FieldWidget plugin discovery to attributes

Created on 13 February 2024, about 1 year ago
Updated 26 March 2024, about 1 year ago

Problem/Motivation

In πŸ“Œ Use PHP attributes instead of doctrine annotations Fixed we added support for attribute based plugin discovery.
As part of that issue we converted block and action plugins.

This issue is to convert \Drupal\Core\Field\Annotation\FieldWidget plugins to use Attributes.

Proposed resolution

  1. Add a class to represent the new Attribute - Example
  2. Update the plugin manager constructor to include both the attribute and annotation class names - example
  3. Convert all plugins that use the annotation to use the new attribute - example

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Fixed

Version

10.3 ✨

Component
EntityΒ  β†’

Last updated 3 days ago

Created by

πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

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

Merge Requests

Comments & Activities

  • Issue created by @larowlan
  • Assigned to mstrelan
  • Merge request !6629FieldWidget attribute β†’ (Closed) created by mstrelan
  • Pipeline finished with Success
    about 1 year ago
    Total: 611s
    #96282
  • Pipeline finished with Success
    about 1 year ago
    Total: 584s
    #96290
  • Pipeline finished with Success
    about 1 year ago
    Total: 482s
    #96297
  • Status changed to Needs review about 1 year ago
  • Issue was unassigned.
  • Pipeline finished with Failed
    about 1 year ago
    Total: 517s
    #96306
  • Pipeline finished with Success
    about 1 year ago
    Total: 514s
    #96319
  • Pipeline finished with Canceled
    about 1 year ago
    Total: 445s
    #104564
  • Pipeline finished with Success
    about 1 year ago
    #104568
  • Pipeline finished with Success
    about 1 year ago
    Total: 584s
    #107645
  • Status changed to RTBC about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Sorry didn't mean to leave this hanging.

    Based on your last comment seems "Additional annotation keys" isn't a problem I believe.

    Searched for @FieldWidget and all 37 instances in core have been replaced.

    From feedback on other tickets also searched for Field\Annotation\FieldWidget and that was replaced also.

  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    Committed d0e9611 and pushed to 11.x. Thanks!
    Committed 890e58d and pushed to 10.3.x. Thanks!

    diff --git a/core/lib/Drupal/Core/Field/Attribute/FieldWidget.php b/core/lib/Drupal/Core/Field/Attribute/FieldWidget.php
    index f93433e7b2..9b98af3cd5 100644
    --- a/core/lib/Drupal/Core/Field/Attribute/FieldWidget.php
    +++ b/core/lib/Drupal/Core/Field/Attribute/FieldWidget.php
    @@ -12,7 +12,7 @@
      *
      * Widgets handle how fields are displayed in edit forms.
      *
    - * Additional annotation keys for widgets can be defined in
    + * Additional attribute keys for widgets can be defined in
      * hook_field_widget_info_alter().
      *
      * @see \Drupal\Core\Field\WidgetPluginManager
    diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php
    index ddaf9309e6..7656b41d58 100644
    --- a/core/modules/field/field.api.php
    +++ b/core/modules/field/field.api.php
    @@ -173,7 +173,7 @@ function hook_field_storage_config_update_forbid(\Drupal\field\FieldStorageConfi
      *
      * @param array $info
      *   An array of information on existing widget types, as collected by the
    - *   annotation discovery mechanism.
    + *   plugin discovery mechanism.
      */
     function hook_field_widget_info_alter(array &$info) {
       // Let a new field type re-use an existing widget.
    

    Fixed the above on commit. Also did this on the formatter issue too. I agree with @mstrelan that wording of additional keys is odd but saying annotation is worse than attribute so /shrug.

    • alexpott β†’ committed 890e58d7 on 10.3.x
      Issue #3420978 by mstrelan, smustgrave: Convert FieldWidget plugin...
  • Status changed to Fixed about 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024