From 093fe8b293cceaf5993bc0bc241218ba7cb81a1f Mon Sep 17 00:00:00 2001
From: Primoz Hmeljak <primsi@gmail.com>
Date: Tue, 6 May 2025 17:05:47 +0200
Subject: [PATCH 1/4] Issue #3522955: add annotation classes.

---
 src/Attribute/EntityBrowserDisplay.php        | 34 ++++++++++++++
 .../EntityBrowserFieldWidgetDisplay.php       | 33 ++++++++++++++
 .../EntityBrowserSelectionDisplay.php         | 44 +++++++++++++++++++
 src/Attribute/EntityBrowserWidget.php         | 35 +++++++++++++++
 src/Attribute/EntityBrowserWidgetSelector.php | 32 ++++++++++++++
 .../EntityBrowserWidgetValidation.php         | 35 +++++++++++++++
 6 files changed, 213 insertions(+)
 create mode 100644 src/Attribute/EntityBrowserDisplay.php
 create mode 100644 src/Attribute/EntityBrowserFieldWidgetDisplay.php
 create mode 100644 src/Attribute/EntityBrowserSelectionDisplay.php
 create mode 100644 src/Attribute/EntityBrowserWidget.php
 create mode 100644 src/Attribute/EntityBrowserWidgetSelector.php
 create mode 100644 src/Attribute/EntityBrowserWidgetValidation.php

diff --git a/src/Attribute/EntityBrowserDisplay.php b/src/Attribute/EntityBrowserDisplay.php
new file mode 100644
index 0000000..f14455e
--- /dev/null
+++ b/src/Attribute/EntityBrowserDisplay.php
@@ -0,0 +1,34 @@
+<?php
+
+namespace Drupal\entity_browser\Attribute;
+
+use Drupal\Component\Plugin\Attribute\Plugin;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+
+/**
+ * Defines an entity browser display attribute object.
+ *
+ * @see hook_entity_browser_display_info_alter()
+ */
+#[\Attribute(\Attribute::TARGET_CLASS)]
+class EntityBrowserDisplay extends Plugin {
+  /**
+   * Constructs a new EntityBrowserDisplay instance.
+   *
+   * @param string $id
+   *   The plugin ID.
+   * @param \Drupal\Core\StringTranslation\TranslatableMarkup $label
+   *   The human-readable name of the display.
+   * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $description
+   *   A brief description of the display. This will be shown when adding or
+   *   configuring this display.
+   * @param bool $uses_route
+   *   Indicates that display uses route.
+   */
+  public function __construct(
+    public readonly string $id,
+    public readonly TranslatableMarkup $label,
+    public readonly ?TranslatableMarkup $description = NULL,
+    public bool $uses_route = FALSE,
+  ) {}
+}
diff --git a/src/Attribute/EntityBrowserFieldWidgetDisplay.php b/src/Attribute/EntityBrowserFieldWidgetDisplay.php
new file mode 100644
index 0000000..6a1ee05
--- /dev/null
+++ b/src/Attribute/EntityBrowserFieldWidgetDisplay.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace Drupal\entity_browser\Attribute;
+
+use Drupal\Component\Plugin\Attribute\Plugin;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+
+/**
+ * Defines an entity browser field widget display attribute object.
+ *
+ * @see hook_entity_browser_field_widget_display_info_alter()
+ */
+#[\Attribute(\Attribute::TARGET_CLASS)]
+class EntityBrowserFieldWidgetDisplay extends Plugin {
+
+  /**
+   * Constructs a new SensorPlugin instance.
+   *
+   * @param string $id
+   *   The plugin ID.
+   * @param \Drupal\Core\StringTranslation\TranslatableMarkup $label
+   *   The human-readable name of the field widget display.
+   * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $description
+   *   A brief description of the field widget display. This will be shown when
+   *   adding or configuring this display.
+   */
+  public function __construct(
+    public readonly string $id,
+    public readonly TranslatableMarkup $label,
+    public readonly ?TranslatableMarkup $description = NULL,
+  ) {}
+
+}
diff --git a/src/Attribute/EntityBrowserSelectionDisplay.php b/src/Attribute/EntityBrowserSelectionDisplay.php
new file mode 100644
index 0000000..fdd9942
--- /dev/null
+++ b/src/Attribute/EntityBrowserSelectionDisplay.php
@@ -0,0 +1,44 @@
+<?php
+
+namespace Drupal\entity_browser\Attribute;
+
+use Drupal\Component\Plugin\Attribute\Plugin;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+
+/**
+ * Defines an entity browser selection display attribute object.
+ *
+ * @see hook_entity_browser_selection_display_info_alter()
+ */
+#[\Attribute(\Attribute::TARGET_CLASS)]
+class EntityBrowserSelectionDisplay extends Plugin {
+
+  /**
+   * Constructs a new SensorPlugin instance.
+   *
+   * @param string $id
+   *   The plugin ID.
+   * @param \Drupal\Core\StringTranslation\TranslatableMarkup $label
+   *   The human-readable name of the selection display.
+   * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $description
+   *   A brief description of the selection display. This will be shown when
+   *   adding or configuring this selection display.
+   * @param bool $acceptPreselection
+   *   Preselection support. This will be used by entity browser form element to
+   *   check, if selection display accepts preselection of entities.
+   * @param bool $js_commands
+   *   Indicates that javascript commands can be executed for Selection display.
+   *   Currently supported javascript commands are adding and removing selection
+   *   from selection display. Javascript commands use Ajax requests to load
+   *   relevant changes and makes user experience way better, because form is
+   *   not flashed every time.
+   */
+  public function __construct(
+    public readonly string $id,
+    public readonly TranslatableMarkup $label,
+    public readonly ?TranslatableMarkup $description = NULL,
+    public readonly bool $acceptPreselection = FALSE,
+    public readonly bool $js_commands = FALSE,
+  ) {}
+
+}
diff --git a/src/Attribute/EntityBrowserWidget.php b/src/Attribute/EntityBrowserWidget.php
new file mode 100644
index 0000000..f01f994
--- /dev/null
+++ b/src/Attribute/EntityBrowserWidget.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace Drupal\entity_browser\Attribute;
+
+use Drupal\Component\Plugin\Attribute\Plugin;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+
+/**
+ * Defines an entity browser widget annotation object.
+ *
+ * @see hook_entity_browser_widget_info_alter()
+ */
+#[\Attribute(\Attribute::TARGET_CLASS)]
+class EntityBrowserWidget extends Plugin {
+  /**
+   * Constructs a new SensorPlugin instance.
+   *
+   * @param string $id
+   *   The plugin ID.
+   * @param \Drupal\Core\StringTranslation\TranslatableMarkup $label
+   *   The human-readable name of the widget.
+   * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $description
+   *   A brief description of the widget. This will be shown when adding or
+   *   configuring this widget.
+   * @param bool $auto_select
+   *   Indicates that widget supports auto selection of entities.
+   */
+  public function __construct(
+    public readonly string $id,
+    public readonly TranslatableMarkup $label,
+    public readonly ?TranslatableMarkup $description = NULL,
+    public readonly bool $auto_select = FALSE,
+  ) {}
+
+}
diff --git a/src/Attribute/EntityBrowserWidgetSelector.php b/src/Attribute/EntityBrowserWidgetSelector.php
new file mode 100644
index 0000000..55b6fbf
--- /dev/null
+++ b/src/Attribute/EntityBrowserWidgetSelector.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace Drupal\entity_browser\Attribute;
+
+use Drupal\Component\Plugin\Attribute\Plugin;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+
+/**
+ * Defines an entity browser widget selector attribute object.
+ *
+ * @see hook_entity_browser_widget_selector_info_alter()
+ */
+#[\Attribute(\Attribute::TARGET_CLASS)]
+class EntityBrowserWidgetSelector extends Plugin {
+  /**
+   * Constructs a new SensorPlugin instance.
+   *
+   * @param string $id
+   *   The plugin ID.
+   * @param \Drupal\Core\StringTranslation\TranslatableMarkup $label
+   *   The human-readable name of the widget selector.
+   * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $description
+   *   A brief description of the widget selector. This will be shown when
+   *   adding or configuring this widget selector.
+   */
+  public function __construct(
+    public readonly string $id,
+    public readonly TranslatableMarkup $label,
+    public readonly ?TranslatableMarkup $description = NULL,
+  ) {}
+
+}
diff --git a/src/Attribute/EntityBrowserWidgetValidation.php b/src/Attribute/EntityBrowserWidgetValidation.php
new file mode 100644
index 0000000..7e54e31
--- /dev/null
+++ b/src/Attribute/EntityBrowserWidgetValidation.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace Drupal\entity_browser\Attribute;
+
+use Drupal\Component\Plugin\Attribute\Plugin;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+
+/**
+ * Defines an entity browser widget validation attribute object.
+ *
+ * @see hook_entity_browser_widget_validation_info_alter()
+ */
+#[\Attribute(\Attribute::TARGET_CLASS)]
+class EntityBrowserWidgetValidation extends Plugin {
+  /**
+   * Constructs a new SensorPlugin instance.
+   *
+   * @param string $id
+   *   The plugin ID.
+   * @param \Drupal\Core\StringTranslation\TranslatableMarkup $label
+   *   The human-readable name of the widget validator.
+   * @param string $data_type
+   *   (optional) The data type plugin ID, for which a constraint should be
+   *   added.
+   * @param string $constraint
+   *   (optional) The constraint ID.
+   */
+  public function __construct(
+    public readonly string $id,
+    public readonly TranslatableMarkup $label,
+    public readonly string $data_type,
+    public readonly string $constraint,
+  ) {}
+
+}
-- 
GitLab


From 7211248fa62d8103c2d53332c070e8df3e90ace3 Mon Sep 17 00:00:00 2001
From: Primoz Hmeljak <primsi@gmail.com>
Date: Wed, 7 May 2025 14:41:37 +0200
Subject: [PATCH 2/4] Issue #3522955: convert plugins and some minor cleanup.

---
 src/Attribute/EntityBrowserDisplay.php        |  4 ++--
 .../EntityBrowserFieldWidgetDisplay.php       |  4 ++--
 src/Attribute/EntityBrowserWidget.php         |  4 ++--
 src/Attribute/EntityBrowserWidgetSelector.php |  4 ++--
 .../EntityBrowserWidgetValidation.php         |  9 ++++----
 src/Plugin/EntityBrowser/Display/IFrame.php   | 15 +++++++------
 src/Plugin/EntityBrowser/Display/Modal.php    | 17 +++++++-------
 .../EntityBrowser/Display/Standalone.php      | 15 +++++++------
 .../FieldWidgetDisplay/EntityLabel.php        | 14 +++++++-----
 .../FieldWidgetDisplay/ImageThumbnail.php     | 13 ++++++-----
 .../FieldWidgetDisplay/RenderedEntity.php     | 13 ++++++-----
 .../SelectionDisplay/MultiStepDisplay.php     | 17 +++++++-------
 .../SelectionDisplay/NoDisplay.php            | 17 +++++++-------
 .../EntityBrowser/SelectionDisplay/View.php   | 22 ++++++++++---------
 .../EntityBrowser/Widget/MediaImageUpload.php | 15 +++++++------
 src/Plugin/EntityBrowser/Widget/Upload.php    | 15 +++++++------
 src/Plugin/EntityBrowser/Widget/View.php      | 16 +++++++-------
 .../EntityBrowser/WidgetSelector/DropDown.php | 13 ++++++-----
 .../EntityBrowser/WidgetSelector/Single.php   | 13 ++++++-----
 .../EntityBrowser/WidgetSelector/Tabs.php     | 13 ++++++-----
 .../WidgetValidation/Cardinality.php          | 11 +++++-----
 .../WidgetValidation/EntityType.php           | 15 +++++++------
 .../EntityBrowser/WidgetValidation/File.php   | 11 +++++-----
 23 files changed, 155 insertions(+), 135 deletions(-)

diff --git a/src/Attribute/EntityBrowserDisplay.php b/src/Attribute/EntityBrowserDisplay.php
index f14455e..d332c64 100644
--- a/src/Attribute/EntityBrowserDisplay.php
+++ b/src/Attribute/EntityBrowserDisplay.php
@@ -20,8 +20,8 @@ class EntityBrowserDisplay extends Plugin {
    * @param \Drupal\Core\StringTranslation\TranslatableMarkup $label
    *   The human-readable name of the display.
    * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $description
-   *   A brief description of the display. This will be shown when adding or
-   *   configuring this display.
+   *   (optional) A brief description of the display. This will be shown when
+   *   adding or configuring this display.
    * @param bool $uses_route
    *   Indicates that display uses route.
    */
diff --git a/src/Attribute/EntityBrowserFieldWidgetDisplay.php b/src/Attribute/EntityBrowserFieldWidgetDisplay.php
index 6a1ee05..32c78c8 100644
--- a/src/Attribute/EntityBrowserFieldWidgetDisplay.php
+++ b/src/Attribute/EntityBrowserFieldWidgetDisplay.php
@@ -21,8 +21,8 @@ class EntityBrowserFieldWidgetDisplay extends Plugin {
    * @param \Drupal\Core\StringTranslation\TranslatableMarkup $label
    *   The human-readable name of the field widget display.
    * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $description
-   *   A brief description of the field widget display. This will be shown when
-   *   adding or configuring this display.
+   *   (optional) A brief description of the field widget display. This will be
+   *   shown when adding or configuring this display.
    */
   public function __construct(
     public readonly string $id,
diff --git a/src/Attribute/EntityBrowserWidget.php b/src/Attribute/EntityBrowserWidget.php
index f01f994..94a736c 100644
--- a/src/Attribute/EntityBrowserWidget.php
+++ b/src/Attribute/EntityBrowserWidget.php
@@ -20,8 +20,8 @@ class EntityBrowserWidget extends Plugin {
    * @param \Drupal\Core\StringTranslation\TranslatableMarkup $label
    *   The human-readable name of the widget.
    * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $description
-   *   A brief description of the widget. This will be shown when adding or
-   *   configuring this widget.
+   *   (optional) A brief description of the widget. This will be shown when
+   *   adding or configuring this widget.
    * @param bool $auto_select
    *   Indicates that widget supports auto selection of entities.
    */
diff --git a/src/Attribute/EntityBrowserWidgetSelector.php b/src/Attribute/EntityBrowserWidgetSelector.php
index 55b6fbf..d789822 100644
--- a/src/Attribute/EntityBrowserWidgetSelector.php
+++ b/src/Attribute/EntityBrowserWidgetSelector.php
@@ -20,8 +20,8 @@ class EntityBrowserWidgetSelector extends Plugin {
    * @param \Drupal\Core\StringTranslation\TranslatableMarkup $label
    *   The human-readable name of the widget selector.
    * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $description
-   *   A brief description of the widget selector. This will be shown when
-   *   adding or configuring this widget selector.
+   *   (optional) A brief description of the widget selector. This will be shown
+   *   when adding or configuring this widget selector.
    */
   public function __construct(
     public readonly string $id,
diff --git a/src/Attribute/EntityBrowserWidgetValidation.php b/src/Attribute/EntityBrowserWidgetValidation.php
index 7e54e31..9a995e4 100644
--- a/src/Attribute/EntityBrowserWidgetValidation.php
+++ b/src/Attribute/EntityBrowserWidgetValidation.php
@@ -12,6 +12,7 @@ use Drupal\Core\StringTranslation\TranslatableMarkup;
  */
 #[\Attribute(\Attribute::TARGET_CLASS)]
 class EntityBrowserWidgetValidation extends Plugin {
+
   /**
    * Constructs a new SensorPlugin instance.
    *
@@ -19,17 +20,17 @@ class EntityBrowserWidgetValidation extends Plugin {
    *   The plugin ID.
    * @param \Drupal\Core\StringTranslation\TranslatableMarkup $label
    *   The human-readable name of the widget validator.
-   * @param string $data_type
+   * @param string|null $data_type
    *   (optional) The data type plugin ID, for which a constraint should be
    *   added.
-   * @param string $constraint
+   * @param string|null $constraint
    *   (optional) The constraint ID.
    */
   public function __construct(
     public readonly string $id,
     public readonly TranslatableMarkup $label,
-    public readonly string $data_type,
-    public readonly string $constraint,
+    public readonly ?string $data_type = NULL,
+    public readonly ?string $constraint = NULL,
   ) {}
 
 }
diff --git a/src/Plugin/EntityBrowser/Display/IFrame.php b/src/Plugin/EntityBrowser/Display/IFrame.php
index 4f0252f..74094f4 100644
--- a/src/Plugin/EntityBrowser/Display/IFrame.php
+++ b/src/Plugin/EntityBrowser/Display/IFrame.php
@@ -4,7 +4,9 @@ namespace Drupal\entity_browser\Plugin\EntityBrowser\Display;
 
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 use Drupal\Core\Url;
+use Drupal\entity_browser\Attribute\EntityBrowserDisplay;
 use Drupal\entity_browser\DisplayBase;
 use Drupal\entity_browser\DisplayRouterInterface;
 use Drupal\entity_browser\Events\AlterEntityBrowserDisplayData;
@@ -15,14 +17,13 @@ use Symfony\Component\HttpKernel\Event\ResponseEvent;
 
 /**
  * Presents entity browser in an iFrame.
- *
- * @EntityBrowserDisplay(
- *   id = "iframe",
- *   label = @Translation("iFrame"),
- *   description = @Translation("Displays the entity browser in an iFrame container embedded into the main page."),
- *   uses_route = TRUE
- * )
  */
+#[EntityBrowserDisplay(
+  id: 'iframe',
+  label: new TranslatableMarkup('iFrame'),
+  description: new TranslatableMarkup('Displays the entity browser in an iFrame container embedded into the main page.'),
+  uses_route: TRUE
+)]
 class IFrame extends DisplayBase implements DisplayRouterInterface {
 
   /**
diff --git a/src/Plugin/EntityBrowser/Display/Modal.php b/src/Plugin/EntityBrowser/Display/Modal.php
index 9070886..45191c2 100644
--- a/src/Plugin/EntityBrowser/Display/Modal.php
+++ b/src/Plugin/EntityBrowser/Display/Modal.php
@@ -5,7 +5,9 @@ namespace Drupal\entity_browser\Plugin\EntityBrowser\Display;
 use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\NestedArray;
 use Drupal\Core\Ajax\OpenDialogCommand;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 use Drupal\Core\Url;
+use Drupal\entity_browser\Attribute\EntityBrowserDisplay;
 use Drupal\entity_browser\DisplayBase;
 use Drupal\entity_browser\Events\Events;
 use Drupal\entity_browser\Events\RegisterJSCallbacks;
@@ -14,15 +16,14 @@ use Drupal\Core\Form\FormStateInterface;
 use Drupal\entity_browser\Events\AlterEntityBrowserDisplayData;
 
 /**
- * Presents entity browser in an Modal.
- *
- * @EntityBrowserDisplay(
- *   id = "modal",
- *   label = @Translation("Modal"),
- *   description = @Translation("Displays the entity browser in a modal window."),
- *   uses_route = TRUE
- * )
+ * Presents entity browser in a Modal.
  */
+#[EntityBrowserDisplay(
+  id: 'modal',
+  label: new TranslatableMarkup('Modal'),
+  description: new TranslatableMarkup('Displays the entity browser in a modal window.'),
+  uses_route: TRUE
+)]
 class Modal extends IFrame {
 
   /**
diff --git a/src/Plugin/EntityBrowser/Display/Standalone.php b/src/Plugin/EntityBrowser/Display/Standalone.php
index 47a5ab2..461b159 100644
--- a/src/Plugin/EntityBrowser/Display/Standalone.php
+++ b/src/Plugin/EntityBrowser/Display/Standalone.php
@@ -2,20 +2,21 @@
 
 namespace Drupal\entity_browser\Plugin\EntityBrowser\Display;
 
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+use Drupal\entity_browser\Attribute\EntityBrowserDisplay;
 use Drupal\entity_browser\DisplayBase;
 use Drupal\entity_browser\DisplayRouterInterface;
 use Drupal\Core\Form\FormStateInterface;
 
 /**
  * Presents entity browser as a standalone form.
- *
- * @EntityBrowserDisplay(
- *   id = "standalone",
- *   label = @Translation("Standalone form"),
- *   description = @Translation("Displays the entity browser as a standalone form. Only intended for testing or very specific use cases."),
- *   uses_route = TRUE
- * )
  */
+#[EntityBrowserDisplay(
+  id: 'standalone',
+  label: new TranslatableMarkup('Standalone form'),
+  description: new TranslatableMarkup('Displays the entity browser as a standalone form. Only intended for testing or very specific use cases.'),
+  uses_route: TRUE
+)]
 class Standalone extends DisplayBase implements DisplayRouterInterface {
 
   /**
diff --git a/src/Plugin/EntityBrowser/FieldWidgetDisplay/EntityLabel.php b/src/Plugin/EntityBrowser/FieldWidgetDisplay/EntityLabel.php
index bfd24d8..e0c1f7b 100644
--- a/src/Plugin/EntityBrowser/FieldWidgetDisplay/EntityLabel.php
+++ b/src/Plugin/EntityBrowser/FieldWidgetDisplay/EntityLabel.php
@@ -6,18 +6,20 @@ use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+use Drupal\entity_browser\Attribute\EntityBrowserDisplay;
+use Drupal\entity_browser\Attribute\EntityBrowserFieldWidgetDisplay;
 use Drupal\entity_browser\FieldWidgetDisplayBase;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
  * Displays a label of the entity.
- *
- * @EntityBrowserFieldWidgetDisplay(
- *   id = "label",
- *   label = @Translation("Entity label"),
- *   description = @Translation("Displays entity with a label.")
- * )
  */
+#[EntityBrowserFieldWidgetDisplay(
+  id: 'label',
+  label: new TranslatableMarkup('Entity label'),
+  description: new TranslatableMarkup('Displays entity with a label.'),
+)]
 class EntityLabel extends FieldWidgetDisplayBase implements ContainerFactoryPluginInterface {
 
   /**
diff --git a/src/Plugin/EntityBrowser/FieldWidgetDisplay/ImageThumbnail.php b/src/Plugin/EntityBrowser/FieldWidgetDisplay/ImageThumbnail.php
index 3b371b6..391e011 100644
--- a/src/Plugin/EntityBrowser/FieldWidgetDisplay/ImageThumbnail.php
+++ b/src/Plugin/EntityBrowser/FieldWidgetDisplay/ImageThumbnail.php
@@ -7,19 +7,20 @@ use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Entity\EntityTypeInterface;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+use Drupal\entity_browser\Attribute\EntityBrowserFieldWidgetDisplay;
 use Drupal\entity_browser\FieldWidgetDisplayBase;
 use Drupal\file\FileInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
  * Displays image thumbnail.
- *
- * @EntityBrowserFieldWidgetDisplay(
- *   id = "thumbnail",
- *   label = @Translation("Image thumbnail"),
- *   description = @Translation("Displays image files as thumbnails")
- * )
  */
+#[EntityBrowserFieldWidgetDisplay(
+  id: 'thumbnail',
+  label: new TranslatableMarkup('Image thumbnail'),
+  description: new TranslatableMarkup('Displays image files as thumbnails'),
+)]
 class ImageThumbnail extends FieldWidgetDisplayBase implements ContainerFactoryPluginInterface {
 
   /**
diff --git a/src/Plugin/EntityBrowser/FieldWidgetDisplay/RenderedEntity.php b/src/Plugin/EntityBrowser/FieldWidgetDisplay/RenderedEntity.php
index 3c900c5..f34d169 100644
--- a/src/Plugin/EntityBrowser/FieldWidgetDisplay/RenderedEntity.php
+++ b/src/Plugin/EntityBrowser/FieldWidgetDisplay/RenderedEntity.php
@@ -6,18 +6,19 @@ use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+use Drupal\entity_browser\Attribute\EntityBrowserFieldWidgetDisplay;
 use Drupal\entity_browser\FieldWidgetDisplayBase;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
  * Displays the fully rendered entity.
- *
- * @EntityBrowserFieldWidgetDisplay(
- *   id = "rendered_entity",
- *   label = @Translation("Rendered entity"),
- *   description = @Translation("Displays fully rendered entity.")
- * )
  */
+#[EntityBrowserFieldWidgetDisplay(
+  id: 'rendered_entity',
+  label: new TranslatableMarkup('Rendered entity'),
+  description: new TranslatableMarkup('Displays image files as thumbnails'),
+)]
 class RenderedEntity extends FieldWidgetDisplayBase implements ContainerFactoryPluginInterface {
 
   /**
diff --git a/src/Plugin/EntityBrowser/SelectionDisplay/MultiStepDisplay.php b/src/Plugin/EntityBrowser/SelectionDisplay/MultiStepDisplay.php
index 7178ce5..1144c19 100644
--- a/src/Plugin/EntityBrowser/SelectionDisplay/MultiStepDisplay.php
+++ b/src/Plugin/EntityBrowser/SelectionDisplay/MultiStepDisplay.php
@@ -7,20 +7,21 @@ use Drupal\Core\Ajax\AjaxResponse;
 use Drupal\Core\Ajax\InvokeCommand;
 use Drupal\Core\Ajax\ReplaceCommand;
 use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+use Drupal\entity_browser\Attribute\EntityBrowserSelectionDisplay;
 use Drupal\entity_browser\SelectionDisplayBase;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
  * Show current selection and delivers selected entities.
- *
- * @EntityBrowserSelectionDisplay(
- *   id = "multi_step_display",
- *   label = @Translation("Multi step selection display"),
- *   description = @Translation("Shows the current selection display, allowing to mix elements selected through different widgets in several steps."),
- *   acceptPreselection = TRUE,
- *   js_commands = TRUE
- * )
  */
+#[EntityBrowserSelectionDisplay(
+  id: 'multi_step_display',
+  label: new TranslatableMarkup('Multi step selection display'),
+  description: new TranslatableMarkup('Shows the current selection display, allowing to mix elements selected through different widgets in several steps.'),
+  acceptPreselection: TRUE,
+  js_commands: TRUE,
+)]
 class MultiStepDisplay extends SelectionDisplayBase {
 
   /**
diff --git a/src/Plugin/EntityBrowser/SelectionDisplay/NoDisplay.php b/src/Plugin/EntityBrowser/SelectionDisplay/NoDisplay.php
index 8e9d184..8afee86 100644
--- a/src/Plugin/EntityBrowser/SelectionDisplay/NoDisplay.php
+++ b/src/Plugin/EntityBrowser/SelectionDisplay/NoDisplay.php
@@ -3,19 +3,20 @@
 namespace Drupal\entity_browser\Plugin\EntityBrowser\SelectionDisplay;
 
 use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+use Drupal\entity_browser\Attribute\EntityBrowserSelectionDisplay;
 use Drupal\entity_browser\SelectionDisplayBase;
 
 /**
  * Does not show current selection and immediately delivers selected entities.
- *
- * @EntityBrowserSelectionDisplay(
- *   id = "no_display",
- *   label = @Translation("No selection display"),
- *   description = @Translation("Skips the current selection display and immediately delivers the entities selected."),
- *   acceptPreselection = FALSE,
- *   js_commands = FALSE
- * )
  */
+#[EntityBrowserSelectionDisplay(
+  id: 'no_display',
+  label: new TranslatableMarkup('No selection display'),
+  description: new TranslatableMarkup('Skips the current selection display and immediately delivers the entities selected.'),
+  acceptPreselection: FALSE,
+  js_commands: FALSE,
+)]
 class NoDisplay extends SelectionDisplayBase {
 
   /**
diff --git a/src/Plugin/EntityBrowser/SelectionDisplay/View.php b/src/Plugin/EntityBrowser/SelectionDisplay/View.php
index 1542d7f..b476ad1 100644
--- a/src/Plugin/EntityBrowser/SelectionDisplay/View.php
+++ b/src/Plugin/EntityBrowser/SelectionDisplay/View.php
@@ -4,22 +4,24 @@ namespace Drupal\entity_browser\Plugin\EntityBrowser\SelectionDisplay;
 
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+use Drupal\entity_browser\Attribute\EntityBrowserSelectionDisplay;
 use Drupal\entity_browser\SelectionDisplayBase;
 use Drupal\views\Views;
 use Drupal\views\Entity\View as ViewEntity;
 
 /**
  * Displays current selection in a View.
- *
- * @EntityBrowserSelectionDisplay(
- *   id = "view",
- *   label = @Translation("View selection display"),
- *   description = @Translation("Use a pre-configured view as selection area."),
- *   acceptPreselection = TRUE,
- *   provider = "views",
- *   js_commands = FALSE
- * )
  */
+#[EntityBrowserSelectionDisplay(
+  id: 'view',
+  label: new TranslatableMarkup('View selection display'),
+  description: new TranslatableMarkup('Use a pre-configured view as selection area.'),
+  acceptPreselection: TRUE,
+  js_commands: FALSE,
+  // @todo Is this a leftover?
+  // provider: 'views',
+)]
 class View extends SelectionDisplayBase {
 
   /**
@@ -113,7 +115,7 @@ class View extends SelectionDisplayBase {
     $values = $form_state->getValues();
 
     if (!empty($values['view'])) {
-      list($view_id, $display_id) = explode('.', $values['view']);
+      [$view_id, $display_id] = explode('.', $values['view']);
       $this->configuration['view'] = $view_id;
       $this->configuration['view_display'] = $display_id;
     }
diff --git a/src/Plugin/EntityBrowser/Widget/MediaImageUpload.php b/src/Plugin/EntityBrowser/Widget/MediaImageUpload.php
index 34c5383..40ac88f 100644
--- a/src/Plugin/EntityBrowser/Widget/MediaImageUpload.php
+++ b/src/Plugin/EntityBrowser/Widget/MediaImageUpload.php
@@ -3,20 +3,21 @@
 namespace Drupal\entity_browser\Plugin\EntityBrowser\Widget;
 
 use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 use Drupal\Core\Url;
+use Drupal\entity_browser\Attribute\EntityBrowserWidget;
 use Drupal\entity_browser\Plugin\EntityBrowser\Widget\Upload as FileUpload;
 use Drupal\media\MediaInterface;
 
 /**
  * Uses upload to create media images.
- *
- * @EntityBrowserWidget(
- *   id = "media_image_upload",
- *   label = @Translation("Upload images as media items"),
- *   description = @Translation("Upload widget that will create media entities of the uploaded images."),
- *   auto_select = FALSE
- * )
  */
+#[EntityBrowserWidget(
+  id: 'media_image_upload',
+  label: new TranslatableMarkup('Upload images as media items'),
+  description: new TranslatableMarkup('Upload widget that will create media entities of the uploaded images.'),
+  auto_select: FALSE
+)]
 class MediaImageUpload extends FileUpload {
 
   /**
diff --git a/src/Plugin/EntityBrowser/Widget/Upload.php b/src/Plugin/EntityBrowser/Widget/Upload.php
index 065b2ea..95912a0 100644
--- a/src/Plugin/EntityBrowser/Widget/Upload.php
+++ b/src/Plugin/EntityBrowser/Widget/Upload.php
@@ -4,20 +4,21 @@ namespace Drupal\entity_browser\Plugin\EntityBrowser\Widget;
 
 use Drupal\Component\Utility\NestedArray;
 use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+use Drupal\entity_browser\Attribute\EntityBrowserWidget;
 use Drupal\entity_browser\WidgetBase;
 use Drupal\file\FileInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
  * Adds an upload field browser's widget.
- *
- * @EntityBrowserWidget(
- *   id = "upload",
- *   label = @Translation("Upload"),
- *   description = @Translation("Adds an upload field browser's widget."),
- *   auto_select = FALSE
- * )
  */
+#[EntityBrowserWidget(
+  id: 'upload',
+  label: new TranslatableMarkup('Upload'),
+  description: new TranslatableMarkup("Adds an upload field browser's widget."),
+  auto_select: FALSE
+)]
 class Upload extends WidgetBase {
 
   /**
diff --git a/src/Plugin/EntityBrowser/Widget/View.php b/src/Plugin/EntityBrowser/Widget/View.php
index f445d45..acdb683 100644
--- a/src/Plugin/EntityBrowser/Widget/View.php
+++ b/src/Plugin/EntityBrowser/Widget/View.php
@@ -6,7 +6,9 @@ use Drupal\Component\Plugin\Exception\PluginNotFoundException;
 use Drupal\Core\Access\AccessResult;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Render\Element;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 use Drupal\Core\Url;
+use Drupal\entity_browser\Attribute\EntityBrowserWidget;
 use Drupal\entity_browser\WidgetBase;
 use Drupal\views\Entity\View as ViewEntity;
 use Drupal\views\Views;
@@ -14,15 +16,13 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
  * Uses a view to provide entity listing in a browser's widget.
- *
- * @EntityBrowserWidget(
- *   id = "view",
- *   label = @Translation("View"),
- *   provider = "views",
- *   description = @Translation("Uses a view to provide entity listing in a browser's widget."),
- *   auto_select = TRUE
- * )
  */
+#[EntityBrowserWidget(
+  id: 'view',
+  label: new TranslatableMarkup('View'),
+  description: new TranslatableMarkup("Uses a view to provide entity listing in a browser's widget."),
+  auto_select: TRUE
+)]
 class View extends WidgetBase {
 
   /**
diff --git a/src/Plugin/EntityBrowser/WidgetSelector/DropDown.php b/src/Plugin/EntityBrowser/WidgetSelector/DropDown.php
index 8b71ba5..7a12b55 100644
--- a/src/Plugin/EntityBrowser/WidgetSelector/DropDown.php
+++ b/src/Plugin/EntityBrowser/WidgetSelector/DropDown.php
@@ -2,18 +2,19 @@
 
 namespace Drupal\entity_browser\Plugin\EntityBrowser\WidgetSelector;
 
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+use Drupal\entity_browser\Attribute\EntityBrowserWidgetSelector;
 use Drupal\entity_browser\WidgetSelectorBase;
 use Drupal\Core\Form\FormStateInterface;
 
 /**
  * Displays widgets in a select list.
- *
- * @EntityBrowserWidgetSelector(
- *   id = "drop_down",
- *   label = @Translation("Drop down widget"),
- *   description = @Translation("Displays the widgets in a drop down.")
- * )
  */
+#[EntityBrowserWidgetSelector(
+  id: 'drop_down',
+  label: new TranslatableMarkup('Drop down widget'),
+  description: new TranslatableMarkup("Displays the widgets in a drop down."),
+)]
 class DropDown extends WidgetSelectorBase {
 
   /**
diff --git a/src/Plugin/EntityBrowser/WidgetSelector/Single.php b/src/Plugin/EntityBrowser/WidgetSelector/Single.php
index d86204b..a423063 100644
--- a/src/Plugin/EntityBrowser/WidgetSelector/Single.php
+++ b/src/Plugin/EntityBrowser/WidgetSelector/Single.php
@@ -2,18 +2,19 @@
 
 namespace Drupal\entity_browser\Plugin\EntityBrowser\WidgetSelector;
 
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+use Drupal\entity_browser\Attribute\EntityBrowserWidgetSelector;
 use Drupal\entity_browser\WidgetSelectorBase;
 use Drupal\Core\Form\FormStateInterface;
 
 /**
  * Displays only first widget.
- *
- * @EntityBrowserWidgetSelector(
- *   id = "single",
- *   label = @Translation("Single widget"),
- *   description = @Translation("Displays only the first configured widget. Use this if you plan to have only one widget available.")
- * )
  */
+#[EntityBrowserWidgetSelector(
+  id: 'single',
+  label: new TranslatableMarkup('Single widget'),
+  description: new TranslatableMarkup("Displays only the first configured widget. Use this if you plan to have only one widget available."),
+)]
 class Single extends WidgetSelectorBase {
 
   /**
diff --git a/src/Plugin/EntityBrowser/WidgetSelector/Tabs.php b/src/Plugin/EntityBrowser/WidgetSelector/Tabs.php
index aad1e56..c70356a 100644
--- a/src/Plugin/EntityBrowser/WidgetSelector/Tabs.php
+++ b/src/Plugin/EntityBrowser/WidgetSelector/Tabs.php
@@ -2,18 +2,19 @@
 
 namespace Drupal\entity_browser\Plugin\EntityBrowser\WidgetSelector;
 
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+use Drupal\entity_browser\Attribute\EntityBrowserWidgetSelector;
 use Drupal\entity_browser\WidgetSelectorBase;
 use Drupal\Core\Form\FormStateInterface;
 
 /**
  * Displays entity browser widgets as tabs.
- *
- * @EntityBrowserWidgetSelector(
- *   id = "tabs",
- *   label = @Translation("Tabs"),
- *   description = @Translation("Creates horizontal tabs on the top of the entity browser, each tab representing one available widget.")
- * )
  */
+#[EntityBrowserWidgetSelector(
+  id: 'tabs',
+  label: new TranslatableMarkup('Tabs'),
+  description: new TranslatableMarkup("Creates horizontal tabs on the top of the entity browser, each tab representing one available widget."),
+)]
 class Tabs extends WidgetSelectorBase {
 
   /**
diff --git a/src/Plugin/EntityBrowser/WidgetValidation/Cardinality.php b/src/Plugin/EntityBrowser/WidgetValidation/Cardinality.php
index e26d3f6..d7a8c87 100644
--- a/src/Plugin/EntityBrowser/WidgetValidation/Cardinality.php
+++ b/src/Plugin/EntityBrowser/WidgetValidation/Cardinality.php
@@ -2,6 +2,8 @@
 
 namespace Drupal\entity_browser\Plugin\EntityBrowser\WidgetValidation;
 
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+use Drupal\entity_browser\Attribute\EntityBrowserWidgetValidation;
 use Drupal\entity_browser\Element\EntityBrowserElement;
 use Drupal\entity_browser\WidgetValidationBase;
 use Symfony\Component\Validator\ConstraintViolation;
@@ -9,12 +11,11 @@ use Symfony\Component\Validator\ConstraintViolationList;
 
 /**
  * Validates that the widget returns the appropriate number of elements.
- *
- * @EntityBrowserWidgetValidation(
- *   id = "cardinality",
- *   label = @Translation("Cardinality validator")
- * )
  */
+#[EntityBrowserWidgetValidation(
+  id: 'cardinality',
+  label: new TranslatableMarkup('Cardinality validator'),
+)]
 class Cardinality extends WidgetValidationBase {
 
   /**
diff --git a/src/Plugin/EntityBrowser/WidgetValidation/EntityType.php b/src/Plugin/EntityBrowser/WidgetValidation/EntityType.php
index 1b32e47..69fd4e7 100644
--- a/src/Plugin/EntityBrowser/WidgetValidation/EntityType.php
+++ b/src/Plugin/EntityBrowser/WidgetValidation/EntityType.php
@@ -2,16 +2,17 @@
 
 namespace Drupal\entity_browser\Plugin\EntityBrowser\WidgetValidation;
 
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+use Drupal\entity_browser\Attribute\EntityBrowserWidgetValidation;
 use Drupal\entity_browser\WidgetValidationBase;
 
 /**
  * Validates that each passed Entity is of the correct type.
- *
- * @EntityBrowserWidgetValidation(
- *   id = "entity_type",
- *   label = @Translation("Entity type validator"),
- *   data_type = "entity_reference",
- *   constraint = "EntityType"
- * )
  */
+#[EntityBrowserWidgetValidation(
+  id: 'entity_type',
+  label: new TranslatableMarkup('Entity type validator'),
+  data_type: 'entity_reference',
+  constraint: 'EntityType'
+)]
 class EntityType extends WidgetValidationBase {}
diff --git a/src/Plugin/EntityBrowser/WidgetValidation/File.php b/src/Plugin/EntityBrowser/WidgetValidation/File.php
index f2f763c..d76d564 100644
--- a/src/Plugin/EntityBrowser/WidgetValidation/File.php
+++ b/src/Plugin/EntityBrowser/WidgetValidation/File.php
@@ -2,6 +2,8 @@
 
 namespace Drupal\entity_browser\Plugin\EntityBrowser\WidgetValidation;
 
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+use Drupal\entity_browser\Attribute\EntityBrowserWidgetValidation;
 use Drupal\entity_browser\WidgetValidationBase;
 use Drupal\file\Validation\FileValidatorInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -10,12 +12,11 @@ use Symfony\Component\Validator\ConstraintViolationList;
 
 /**
  * Validates a file based on passed validators.
- *
- * @EntityBrowserWidgetValidation(
- *   id = "file",
- *   label = @Translation("File validator")
- * )
  */
+#[EntityBrowserWidgetValidation(
+  id: 'file',
+  label: new TranslatableMarkup('File validator'),
+)]
 class File extends WidgetValidationBase {
 
   /**
-- 
GitLab


From 0cece31fd36fd2e3b504cdea5e612d1fd406311f Mon Sep 17 00:00:00 2001
From: Primoz Hmeljak <primsi@gmail.com>
Date: Wed, 7 May 2025 16:15:17 +0200
Subject: [PATCH 3/4] Issue #3522955: update the managers.

---
 src/DisplayManager.php            | 2 +-
 src/FieldWidgetDisplayManager.php | 2 +-
 src/SelectionDisplayManager.php   | 2 +-
 src/WidgetManager.php             | 2 +-
 src/WidgetSelectorManager.php     | 2 +-
 src/WidgetValidationManager.php   | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/DisplayManager.php b/src/DisplayManager.php
index 44a0138..e3f1a9c 100644
--- a/src/DisplayManager.php
+++ b/src/DisplayManager.php
@@ -23,7 +23,7 @@ class DisplayManager extends DefaultPluginManager {
    *   The module handler.
    */
   public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
-    parent::__construct('Plugin/EntityBrowser/Display', $namespaces, $module_handler, 'Drupal\entity_browser\DisplayInterface', 'Drupal\entity_browser\Annotation\EntityBrowserDisplay');
+    parent::__construct('Plugin/EntityBrowser/Display', $namespaces, $module_handler, 'Drupal\entity_browser\DisplayInterface', 'Drupal\entity_browser\Attribute\EntityBrowserDisplay', 'Drupal\entity_browser\Annotation\EntityBrowserDisplay');
 
     $this->alterInfo('entity_browser_display_info');
     $this->setCacheBackend($cache_backend, 'entity_browser_display_plugins');
diff --git a/src/FieldWidgetDisplayManager.php b/src/FieldWidgetDisplayManager.php
index 90b6f4a..70cb9a3 100644
--- a/src/FieldWidgetDisplayManager.php
+++ b/src/FieldWidgetDisplayManager.php
@@ -23,7 +23,7 @@ class FieldWidgetDisplayManager extends DefaultPluginManager {
    *   The module handler.
    */
   public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
-    parent::__construct('Plugin/EntityBrowser/FieldWidgetDisplay', $namespaces, $module_handler, 'Drupal\entity_browser\FieldWidgetDisplayInterface', 'Drupal\entity_browser\Annotation\EntityBrowserFieldWidgetDisplay');
+    parent::__construct('Plugin/EntityBrowser/FieldWidgetDisplay', $namespaces, $module_handler, 'Drupal\entity_browser\FieldWidgetDisplayInterface', 'Drupal\entity_browser\Attribute\EntityBrowserFieldWidgetDisplay', 'Drupal\entity_browser\Annotation\EntityBrowserFieldWidgetDisplay');
 
     $this->alterInfo('entity_browser_field_widget_display_info');
     $this->setCacheBackend($cache_backend, 'entity_browser_field_widget_display_plugins');
diff --git a/src/SelectionDisplayManager.php b/src/SelectionDisplayManager.php
index 537d9f8..e5dffe0 100644
--- a/src/SelectionDisplayManager.php
+++ b/src/SelectionDisplayManager.php
@@ -23,7 +23,7 @@ class SelectionDisplayManager extends DefaultPluginManager {
    *   The module handler.
    */
   public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
-    parent::__construct('Plugin/EntityBrowser/SelectionDisplay', $namespaces, $module_handler, 'Drupal\entity_browser\SelectionDisplayInterface', 'Drupal\entity_browser\Annotation\EntityBrowserSelectionDisplay');
+    parent::__construct('Plugin/EntityBrowser/SelectionDisplay', $namespaces, $module_handler, 'Drupal\entity_browser\SelectionDisplayInterface', 'Drupal\entity_browser\Attribute\EntityBrowserSelectionDisplay', 'Drupal\entity_browser\Annotation\EntityBrowserSelectionDisplay');
 
     $this->alterInfo('entity_browser_selection_display_info');
     $this->setCacheBackend($cache_backend, 'entity_browser_selection_display_plugins');
diff --git a/src/WidgetManager.php b/src/WidgetManager.php
index 04557a0..9db9eee 100644
--- a/src/WidgetManager.php
+++ b/src/WidgetManager.php
@@ -23,7 +23,7 @@ class WidgetManager extends DefaultPluginManager {
    *   The module handler.
    */
   public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
-    parent::__construct('Plugin/EntityBrowser/Widget', $namespaces, $module_handler, 'Drupal\entity_browser\WidgetInterface', 'Drupal\entity_browser\Annotation\EntityBrowserWidget');
+    parent::__construct('Plugin/EntityBrowser/Widget', $namespaces, $module_handler, 'Drupal\entity_browser\WidgetInterface', 'Drupal\entity_browser\Attribute\EntityBrowserWidget', 'Drupal\entity_browser\Annotation\EntityBrowserWidget');
 
     $this->alterInfo('entity_browser_widget_info');
     $this->setCacheBackend($cache_backend, 'entity_browser_widget_plugins');
diff --git a/src/WidgetSelectorManager.php b/src/WidgetSelectorManager.php
index b5d2f51..a737306 100644
--- a/src/WidgetSelectorManager.php
+++ b/src/WidgetSelectorManager.php
@@ -23,7 +23,7 @@ class WidgetSelectorManager extends DefaultPluginManager {
    *   The module handler.
    */
   public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
-    parent::__construct('Plugin/EntityBrowser/WidgetSelector', $namespaces, $module_handler, 'Drupal\entity_browser\WidgetSelectorInterface', 'Drupal\entity_browser\Annotation\EntityBrowserWidgetSelector');
+    parent::__construct('Plugin/EntityBrowser/WidgetSelector', $namespaces, $module_handler, 'Drupal\entity_browser\WidgetSelectorInterface', 'Drupal\entity_browser\Attribute\EntityBrowserWidgetSelector', 'Drupal\entity_browser\Annotation\EntityBrowserWidgetSelector');
 
     $this->alterInfo('entity_browser_widget_selector_info');
     $this->setCacheBackend($cache_backend, 'entity_browser_widget_selector_plugins');
diff --git a/src/WidgetValidationManager.php b/src/WidgetValidationManager.php
index eb8a6a6..26f00dd 100644
--- a/src/WidgetValidationManager.php
+++ b/src/WidgetValidationManager.php
@@ -23,7 +23,7 @@ class WidgetValidationManager extends DefaultPluginManager {
    *   The module handler.
    */
   public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
-    parent::__construct('Plugin/EntityBrowser/WidgetValidation', $namespaces, $module_handler, 'Drupal\entity_browser\WidgetValidationInterface', 'Drupal\entity_browser\Annotation\EntityBrowserWidgetValidation');
+    parent::__construct('Plugin/EntityBrowser/WidgetValidation', $namespaces, $module_handler, 'Drupal\entity_browser\WidgetValidationInterface', 'Drupal\entity_browser\Attribute\EntityBrowserWidgetValidation', 'Drupal\entity_browser\Annotation\EntityBrowserWidgetValidation');
 
     $this->alterInfo('entity_browser_widget_validation_info');
     $this->setCacheBackend($cache_backend, 'entity_browser_widget_validation_plugins');
-- 
GitLab


From 5c7948cbe45e5962b7832772939fcb548709c777 Mon Sep 17 00:00:00 2001
From: Primoz Hmeljak <primsi@gmail.com>
Date: Wed, 7 May 2025 17:15:46 +0200
Subject: [PATCH 4/4] Issue #3522955: add the provider arg.

---
 src/Attribute/EntityBrowserDisplay.php             | 1 +
 src/Attribute/EntityBrowserFieldWidgetDisplay.php  | 1 +
 src/Attribute/EntityBrowserSelectionDisplay.php    | 1 +
 src/Attribute/EntityBrowserWidget.php              | 1 +
 src/Attribute/EntityBrowserWidgetSelector.php      | 1 +
 src/Attribute/EntityBrowserWidgetValidation.php    | 1 +
 src/Plugin/EntityBrowser/SelectionDisplay/View.php | 3 +--
 src/Plugin/EntityBrowser/Widget/View.php           | 3 ++-
 8 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/Attribute/EntityBrowserDisplay.php b/src/Attribute/EntityBrowserDisplay.php
index d332c64..e96b7fe 100644
--- a/src/Attribute/EntityBrowserDisplay.php
+++ b/src/Attribute/EntityBrowserDisplay.php
@@ -30,5 +30,6 @@ class EntityBrowserDisplay extends Plugin {
     public readonly TranslatableMarkup $label,
     public readonly ?TranslatableMarkup $description = NULL,
     public bool $uses_route = FALSE,
+    public ?string $provider = NULL,
   ) {}
 }
diff --git a/src/Attribute/EntityBrowserFieldWidgetDisplay.php b/src/Attribute/EntityBrowserFieldWidgetDisplay.php
index 32c78c8..312b5bb 100644
--- a/src/Attribute/EntityBrowserFieldWidgetDisplay.php
+++ b/src/Attribute/EntityBrowserFieldWidgetDisplay.php
@@ -28,6 +28,7 @@ class EntityBrowserFieldWidgetDisplay extends Plugin {
     public readonly string $id,
     public readonly TranslatableMarkup $label,
     public readonly ?TranslatableMarkup $description = NULL,
+    public ?string $provider = NULL,
   ) {}
 
 }
diff --git a/src/Attribute/EntityBrowserSelectionDisplay.php b/src/Attribute/EntityBrowserSelectionDisplay.php
index fdd9942..417956c 100644
--- a/src/Attribute/EntityBrowserSelectionDisplay.php
+++ b/src/Attribute/EntityBrowserSelectionDisplay.php
@@ -39,6 +39,7 @@ class EntityBrowserSelectionDisplay extends Plugin {
     public readonly ?TranslatableMarkup $description = NULL,
     public readonly bool $acceptPreselection = FALSE,
     public readonly bool $js_commands = FALSE,
+    public ?string $provider = NULL,
   ) {}
 
 }
diff --git a/src/Attribute/EntityBrowserWidget.php b/src/Attribute/EntityBrowserWidget.php
index 94a736c..e06a926 100644
--- a/src/Attribute/EntityBrowserWidget.php
+++ b/src/Attribute/EntityBrowserWidget.php
@@ -30,6 +30,7 @@ class EntityBrowserWidget extends Plugin {
     public readonly TranslatableMarkup $label,
     public readonly ?TranslatableMarkup $description = NULL,
     public readonly bool $auto_select = FALSE,
+    public ?string $provider = NULL,
   ) {}
 
 }
diff --git a/src/Attribute/EntityBrowserWidgetSelector.php b/src/Attribute/EntityBrowserWidgetSelector.php
index d789822..ec20b71 100644
--- a/src/Attribute/EntityBrowserWidgetSelector.php
+++ b/src/Attribute/EntityBrowserWidgetSelector.php
@@ -27,6 +27,7 @@ class EntityBrowserWidgetSelector extends Plugin {
     public readonly string $id,
     public readonly TranslatableMarkup $label,
     public readonly ?TranslatableMarkup $description = NULL,
+    public ?string $provider = NULL,
   ) {}
 
 }
diff --git a/src/Attribute/EntityBrowserWidgetValidation.php b/src/Attribute/EntityBrowserWidgetValidation.php
index 9a995e4..ac35e16 100644
--- a/src/Attribute/EntityBrowserWidgetValidation.php
+++ b/src/Attribute/EntityBrowserWidgetValidation.php
@@ -31,6 +31,7 @@ class EntityBrowserWidgetValidation extends Plugin {
     public readonly TranslatableMarkup $label,
     public readonly ?string $data_type = NULL,
     public readonly ?string $constraint = NULL,
+    public ?string $provider = NULL,
   ) {}
 
 }
diff --git a/src/Plugin/EntityBrowser/SelectionDisplay/View.php b/src/Plugin/EntityBrowser/SelectionDisplay/View.php
index b476ad1..d0440b1 100644
--- a/src/Plugin/EntityBrowser/SelectionDisplay/View.php
+++ b/src/Plugin/EntityBrowser/SelectionDisplay/View.php
@@ -19,8 +19,7 @@ use Drupal\views\Entity\View as ViewEntity;
   description: new TranslatableMarkup('Use a pre-configured view as selection area.'),
   acceptPreselection: TRUE,
   js_commands: FALSE,
-  // @todo Is this a leftover?
-  // provider: 'views',
+  provider: 'views',
 )]
 class View extends SelectionDisplayBase {
 
diff --git a/src/Plugin/EntityBrowser/Widget/View.php b/src/Plugin/EntityBrowser/Widget/View.php
index acdb683..12638d5 100644
--- a/src/Plugin/EntityBrowser/Widget/View.php
+++ b/src/Plugin/EntityBrowser/Widget/View.php
@@ -21,7 +21,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
   id: 'view',
   label: new TranslatableMarkup('View'),
   description: new TranslatableMarkup("Uses a view to provide entity listing in a browser's widget."),
-  auto_select: TRUE
+  auto_select: TRUE,
+  provider: "views",
 )]
 class View extends WidgetBase {
 
-- 
GitLab