From ff659267d9516df86ac7dde65d6dc4eec30281ed Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Wed, 20 Mar 2024 08:04:05 +0000
Subject: [PATCH] Issue #3426958 by sorlov, godotislate, mstrelan, smustgrave:
 Convert ViewsJoin plugin discovery to attributes

---
 core/modules/views/src/Attribute/ViewsJoin.php  | 17 +++++++++++++++++
 .../Plugin/views/join/CastedIntFieldJoin.php    |  5 +++--
 .../Plugin/views/join/FieldOrLanguageJoin.php   |  4 ++--
 .../src/Plugin/views/join/JoinPluginBase.php    |  2 +-
 .../views/src/Plugin/views/join/Standard.php    |  5 +++--
 .../views/src/Plugin/views/join/Subquery.php    |  4 +++-
 .../src/Plugin/views/join/JoinTest.php          |  4 ++--
 7 files changed, 31 insertions(+), 10 deletions(-)
 create mode 100644 core/modules/views/src/Attribute/ViewsJoin.php

diff --git a/core/modules/views/src/Attribute/ViewsJoin.php b/core/modules/views/src/Attribute/ViewsJoin.php
new file mode 100644
index 000000000000..365b47d75da1
--- /dev/null
+++ b/core/modules/views/src/Attribute/ViewsJoin.php
@@ -0,0 +1,17 @@
+<?php
+
+namespace Drupal\views\Attribute;
+
+use Drupal\Component\Plugin\Attribute\PluginID;
+
+/**
+ * Defines a Plugin attribute object for views join plugins.
+ *
+ * @see \Drupal\views\Plugin\views\join\JoinPluginBase
+ *
+ * @ingroup views_join_handlers
+ */
+#[\Attribute(\Attribute::TARGET_CLASS)]
+class ViewsJoin extends PluginID {
+
+}
diff --git a/core/modules/views/src/Plugin/views/join/CastedIntFieldJoin.php b/core/modules/views/src/Plugin/views/join/CastedIntFieldJoin.php
index fe0fdbc570e8..c091222ae515 100644
--- a/core/modules/views/src/Plugin/views/join/CastedIntFieldJoin.php
+++ b/core/modules/views/src/Plugin/views/join/CastedIntFieldJoin.php
@@ -2,6 +2,8 @@
 
 namespace Drupal\views\Plugin\views\join;
 
+use Drupal\views\Attribute\ViewsJoin;
+
 /**
  * Implementation for the "casted_int_field_join" join.
  *
@@ -11,9 +13,8 @@
  * are strict when comparing numbers and strings.
  *
  * @ingroup views_join_handlers
- *
- * @ViewsJoin("casted_int_field_join")
  */
+#[ViewsJoin("casted_int_field_join")]
 class CastedIntFieldJoin extends JoinPluginBase {
 
   /**
diff --git a/core/modules/views/src/Plugin/views/join/FieldOrLanguageJoin.php b/core/modules/views/src/Plugin/views/join/FieldOrLanguageJoin.php
index 25dcc92bce3f..77c880bdd7bf 100644
--- a/core/modules/views/src/Plugin/views/join/FieldOrLanguageJoin.php
+++ b/core/modules/views/src/Plugin/views/join/FieldOrLanguageJoin.php
@@ -3,6 +3,7 @@
 namespace Drupal\views\Plugin\views\join;
 
 use Drupal\Core\Database\Query\SelectInterface;
+use Drupal\views\Attribute\ViewsJoin;
 
 /**
  * Implementation for the "field OR language" join.
@@ -58,9 +59,8 @@
  * @see views_field_default_views_data()
  *
  * @ingroup views_join_handlers
- *
- * @ViewsJoin("field_or_language_join")
  */
+#[ViewsJoin("field_or_language_join")]
 class FieldOrLanguageJoin extends JoinPluginBase {
 
   /**
diff --git a/core/modules/views/src/Plugin/views/join/JoinPluginBase.php b/core/modules/views/src/Plugin/views/join/JoinPluginBase.php
index 57c18eeee143..daadb546f668 100644
--- a/core/modules/views/src/Plugin/views/join/JoinPluginBase.php
+++ b/core/modules/views/src/Plugin/views/join/JoinPluginBase.php
@@ -14,7 +14,7 @@
  * handle table joins.
  *
  * Views join handlers extend \Drupal\views\Plugin\views\join\JoinPluginBase.
- * They must be annotated with \Drupal\views\Annotation\ViewsJoin annotation,
+ * They must be attributed with \Drupal\views\Attribute\ViewsJoin attribute,
  * and they must be in namespace directory Plugin\views\join.
  *
  * Here are some examples of configuration for the join plugins.
diff --git a/core/modules/views/src/Plugin/views/join/Standard.php b/core/modules/views/src/Plugin/views/join/Standard.php
index c21026ef90b7..50e6d92117d8 100644
--- a/core/modules/views/src/Plugin/views/join/Standard.php
+++ b/core/modules/views/src/Plugin/views/join/Standard.php
@@ -2,13 +2,14 @@
 
 namespace Drupal\views\Plugin\views\join;
 
+use Drupal\views\Attribute\ViewsJoin;
+
 /**
  * Default implementation of the join plugin.
  *
  * @ingroup views_join_handlers
- *
- * @ViewsJoin("standard")
  */
+#[ViewsJoin("standard")]
 class Standard extends JoinPluginBase {
 
 }
diff --git a/core/modules/views/src/Plugin/views/join/Subquery.php b/core/modules/views/src/Plugin/views/join/Subquery.php
index ec9eefd9cf9c..adc52e395065 100644
--- a/core/modules/views/src/Plugin/views/join/Subquery.php
+++ b/core/modules/views/src/Plugin/views/join/Subquery.php
@@ -2,6 +2,8 @@
 
 namespace Drupal\views\Plugin\views\join;
 
+use Drupal\views\Attribute\ViewsJoin;
+
 /**
  * Join handler for relationships that join with a subquery as the left field.
  *
@@ -15,8 +17,8 @@
  * - left_query: The subquery to use in the left side of the join clause.
  *
  * @ingroup views_join_handlers
- * @ViewsJoin("subquery")
  */
+#[ViewsJoin("subquery")]
 class Subquery extends JoinPluginBase {
 
   /**
diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/join/JoinTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/join/JoinTest.php
index 025a7748f35d..83b07725510e 100644
--- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/join/JoinTest.php
+++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/join/JoinTest.php
@@ -2,13 +2,13 @@
 
 namespace Drupal\views_test_data\Plugin\views\join;
 
+use Drupal\views\Attribute\ViewsJoin;
 use Drupal\views\Plugin\views\join\JoinPluginBase;
 
 /**
  * Defines a join test plugin.
- *
- * @ViewsJoin("join_test")
  */
+#[ViewsJoin("join_test")]
 class JoinTest extends JoinPluginBase {
   /**
    * A value which is used to build an additional join condition.
-- 
GitLab