From fc15d5ee53ffcd8aa98fc9dc40e386e713d7163c Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Fri, 15 Mar 2024 14:51:42 +0000 Subject: [PATCH] Issue #3426955 by mstrelan, sorlov, alexpott, smustgrave, godotislate: Convert ViewsField plugin discovery to attributes (cherry picked from commit e0f270ff66281b06c2b33d5bd6a71b7f6576905f) --- .../Plugin/views/field/CommentBulkForm.php | 4 ++-- .../Plugin/views/field/CommentedEntity.php | 4 ++-- .../comment/src/Plugin/views/field/Depth.php | 4 ++-- .../src/Plugin/views/field/EntityLink.php | 4 ++-- .../src/Plugin/views/field/LastTimestamp.php | 4 ++-- .../src/Plugin/views/field/LinkApprove.php | 4 ++-- .../src/Plugin/views/field/LinkReply.php | 4 ++-- .../Plugin/views/field/NodeNewComments.php | 4 ++-- .../views/field/StatisticsLastCommentName.php | 4 ++-- .../views/field/StatisticsLastUpdated.php | 4 ++-- .../src/Plugin/views/field/ContactLink.php | 4 ++-- .../views/field/ModerationStateField.php | 4 ++-- .../Plugin/views/field/TranslationLink.php | 4 ++-- .../Plugin/views/field/ContextualLinks.php | 4 ++-- .../src/Plugin/views/field/DblogMessage.php | 4 ++-- .../Plugin/views/field/DblogOperations.php | 4 ++-- .../file/src/Plugin/views/field/File.php | 4 ++-- .../views/field/HistoryUserTimestamp.php | 4 ++-- .../views/field/MediaLibrarySelectForm.php | 4 ++-- .../node/src/Plugin/views/field/Node.php | 4 ++-- .../src/Plugin/views/field/NodeBulkForm.php | 4 ++-- .../src/Plugin/views/field/RevisionLink.php | 4 ++-- .../Plugin/views/field/RevisionLinkDelete.php | 4 ++-- .../Plugin/views/field/RevisionLinkRevert.php | 4 ++-- .../search/src/Plugin/views/field/Score.php | 4 ++-- .../views/field/NodeCounterTimestamp.php | 4 ++-- .../Plugin/views/field/StatisticsNumeric.php | 4 ++-- .../Plugin/views/field/TaxonomyIndexTid.php | 4 ++-- .../src/Plugin/views/field/TermName.php | 4 ++-- .../src/Plugin/views/field/Permissions.php | 4 ++-- .../user/src/Plugin/views/field/Roles.php | 4 ++-- .../src/Plugin/views/field/UserBulkForm.php | 4 ++-- .../user/src/Plugin/views/field/UserData.php | 4 ++-- .../views/src/Attribute/ViewsField.php | 19 +++++++++++++++++++ .../views/src/Plugin/views/field/Boolean.php | 4 ++-- .../views/src/Plugin/views/field/Broken.php | 4 ++-- .../views/src/Plugin/views/field/BulkForm.php | 4 ++-- .../views/src/Plugin/views/field/Counter.php | 4 ++-- .../views/src/Plugin/views/field/Custom.php | 4 ++-- .../views/src/Plugin/views/field/Date.php | 4 ++-- .../src/Plugin/views/field/Dropbutton.php | 4 ++-- .../src/Plugin/views/field/EntityField.php | 4 ++-- .../src/Plugin/views/field/EntityLabel.php | 4 ++-- .../src/Plugin/views/field/EntityLink.php | 4 ++-- .../Plugin/views/field/EntityLinkDelete.php | 4 ++-- .../src/Plugin/views/field/EntityLinkEdit.php | 4 ++-- .../Plugin/views/field/EntityOperations.php | 4 ++-- .../src/Plugin/views/field/FieldLanguage.php | 4 ++-- .../Plugin/views/field/FieldPluginBase.php | 6 +++--- .../views/src/Plugin/views/field/FileSize.php | 4 ++-- .../src/Plugin/views/field/LanguageField.php | 4 ++-- .../src/Plugin/views/field/MachineName.php | 4 ++-- .../views/src/Plugin/views/field/Markup.php | 4 ++-- .../src/Plugin/views/field/NumericField.php | 4 ++-- .../src/Plugin/views/field/RenderedEntity.php | 4 ++-- .../src/Plugin/views/field/Serialized.php | 4 ++-- .../views/src/Plugin/views/field/Standard.php | 5 +++-- .../src/Plugin/views/field/TimeInterval.php | 4 ++-- .../views/src/Plugin/views/field/Url.php | 4 ++-- .../views/field/FieldFormButtonTest.php | 4 ++-- .../src/Plugin/views/field/FieldTest.php | 4 +++- 61 files changed, 142 insertions(+), 120 deletions(-) create mode 100644 core/modules/views/src/Attribute/ViewsField.php diff --git a/core/modules/comment/src/Plugin/views/field/CommentBulkForm.php b/core/modules/comment/src/Plugin/views/field/CommentBulkForm.php index b67cff227ec..54f072c5c76 100644 --- a/core/modules/comment/src/Plugin/views/field/CommentBulkForm.php +++ b/core/modules/comment/src/Plugin/views/field/CommentBulkForm.php @@ -2,13 +2,13 @@ namespace Drupal\comment\Plugin\views\field; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\BulkForm; /** * Defines a comment operations bulk form element. - * - * @ViewsField("comment_bulk_form") */ +#[ViewsField("comment_bulk_form")] class CommentBulkForm extends BulkForm { /** diff --git a/core/modules/comment/src/Plugin/views/field/CommentedEntity.php b/core/modules/comment/src/Plugin/views/field/CommentedEntity.php index 956bcc70892..0b00eeb4082 100644 --- a/core/modules/comment/src/Plugin/views/field/CommentedEntity.php +++ b/core/modules/comment/src/Plugin/views/field/CommentedEntity.php @@ -2,14 +2,14 @@ namespace Drupal\comment\Plugin\views\field; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\EntityField; use Drupal\views\ResultRow; /** * Views field display for commented entity. - * - * @ViewsField("commented_entity") */ +#[ViewsField("commented_entity")] class CommentedEntity extends EntityField { /** diff --git a/core/modules/comment/src/Plugin/views/field/Depth.php b/core/modules/comment/src/Plugin/views/field/Depth.php index 48fbf432800..ab7dc476151 100644 --- a/core/modules/comment/src/Plugin/views/field/Depth.php +++ b/core/modules/comment/src/Plugin/views/field/Depth.php @@ -2,6 +2,7 @@ namespace Drupal\comment\Plugin\views\field; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\EntityField; use Drupal\views\ResultRow; @@ -9,9 +10,8 @@ use Drupal\views\ResultRow; * Field handler to display the depth of a comment. * * @ingroup views_field_handlers - * - * @ViewsField("comment_depth") */ +#[ViewsField("comment_depth")] class Depth extends EntityField { /** diff --git a/core/modules/comment/src/Plugin/views/field/EntityLink.php b/core/modules/comment/src/Plugin/views/field/EntityLink.php index 6584f21318b..7172918e1b8 100644 --- a/core/modules/comment/src/Plugin/views/field/EntityLink.php +++ b/core/modules/comment/src/Plugin/views/field/EntityLink.php @@ -3,6 +3,7 @@ namespace Drupal\comment\Plugin\views\field; use Drupal\Core\Form\FormStateInterface; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\ResultRow; @@ -10,9 +11,8 @@ use Drupal\views\ResultRow; * Handler for showing comment module's entity links. * * @ingroup views_field_handlers - * - * @ViewsField("comment_entity_link") */ +#[ViewsField("comment_entity_link")] class EntityLink extends FieldPluginBase { /** diff --git a/core/modules/comment/src/Plugin/views/field/LastTimestamp.php b/core/modules/comment/src/Plugin/views/field/LastTimestamp.php index bbae18d54fd..8110b79d373 100644 --- a/core/modules/comment/src/Plugin/views/field/LastTimestamp.php +++ b/core/modules/comment/src/Plugin/views/field/LastTimestamp.php @@ -2,6 +2,7 @@ namespace Drupal\comment\Plugin\views\field; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\Date; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ResultRow; @@ -11,9 +12,8 @@ use Drupal\views\ViewExecutable; * Field handler to display the timestamp of a comment with the count of comments. * * @ingroup views_field_handlers - * - * @ViewsField("comment_last_timestamp") */ +#[ViewsField("comment_last_timestamp")] class LastTimestamp extends Date { /** diff --git a/core/modules/comment/src/Plugin/views/field/LinkApprove.php b/core/modules/comment/src/Plugin/views/field/LinkApprove.php index 86687f52f0f..0209400bc0b 100644 --- a/core/modules/comment/src/Plugin/views/field/LinkApprove.php +++ b/core/modules/comment/src/Plugin/views/field/LinkApprove.php @@ -3,6 +3,7 @@ namespace Drupal\comment\Plugin\views\field; use Drupal\Core\Url; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\LinkBase; use Drupal\views\ResultRow; @@ -10,9 +11,8 @@ use Drupal\views\ResultRow; * Provides a comment approve link. * * @ingroup views_field_handlers - * - * @ViewsField("comment_link_approve") */ +#[ViewsField("comment_link_approve")] class LinkApprove extends LinkBase { /** diff --git a/core/modules/comment/src/Plugin/views/field/LinkReply.php b/core/modules/comment/src/Plugin/views/field/LinkReply.php index 816f341a6c7..9cfb082a669 100644 --- a/core/modules/comment/src/Plugin/views/field/LinkReply.php +++ b/core/modules/comment/src/Plugin/views/field/LinkReply.php @@ -3,6 +3,7 @@ namespace Drupal\comment\Plugin\views\field; use Drupal\Core\Url; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\LinkBase; use Drupal\views\ResultRow; @@ -10,9 +11,8 @@ use Drupal\views\ResultRow; * Field handler to present a link to reply to a comment. * * @ingroup views_field_handlers - * - * @ViewsField("comment_link_reply") */ +#[ViewsField("comment_link_reply")] class LinkReply extends LinkBase { /** diff --git a/core/modules/comment/src/Plugin/views/field/NodeNewComments.php b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php index bb4dca48d97..1ddcb16f4f7 100644 --- a/core/modules/comment/src/Plugin/views/field/NodeNewComments.php +++ b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php @@ -8,6 +8,7 @@ use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\node\Entity\Node; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\NumericField; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ResultRow; @@ -18,9 +19,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * Field handler to display the number of new comments. * * @ingroup views_field_handlers - * - * @ViewsField("node_new_comments") */ +#[ViewsField("node_new_comments")] class NodeNewComments extends NumericField { /** diff --git a/core/modules/comment/src/Plugin/views/field/StatisticsLastCommentName.php b/core/modules/comment/src/Plugin/views/field/StatisticsLastCommentName.php index 58c3e16a681..f6e270c358a 100644 --- a/core/modules/comment/src/Plugin/views/field/StatisticsLastCommentName.php +++ b/core/modules/comment/src/Plugin/views/field/StatisticsLastCommentName.php @@ -3,6 +3,7 @@ namespace Drupal\comment\Plugin\views\field; use Drupal\user\Entity\User; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\ResultRow; @@ -10,9 +11,8 @@ use Drupal\views\ResultRow; * Field handler to present the name of the last comment poster. * * @ingroup views_field_handlers - * - * @ViewsField("comment_ces_last_comment_name") */ +#[ViewsField("comment_ces_last_comment_name")] class StatisticsLastCommentName extends FieldPluginBase { /** diff --git a/core/modules/comment/src/Plugin/views/field/StatisticsLastUpdated.php b/core/modules/comment/src/Plugin/views/field/StatisticsLastUpdated.php index 95b6cb733f2..2662df44c01 100644 --- a/core/modules/comment/src/Plugin/views/field/StatisticsLastUpdated.php +++ b/core/modules/comment/src/Plugin/views/field/StatisticsLastUpdated.php @@ -2,15 +2,15 @@ namespace Drupal\comment\Plugin\views\field; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\Date; /** * Field handler to display the newer of last comment / node updated. * * @ingroup views_field_handlers - * - * @ViewsField("comment_ces_last_updated") */ +#[ViewsField("comment_ces_last_updated")] class StatisticsLastUpdated extends Date { /** diff --git a/core/modules/contact/src/Plugin/views/field/ContactLink.php b/core/modules/contact/src/Plugin/views/field/ContactLink.php index af72aa3313d..eed47f0dd08 100644 --- a/core/modules/contact/src/Plugin/views/field/ContactLink.php +++ b/core/modules/contact/src/Plugin/views/field/ContactLink.php @@ -4,6 +4,7 @@ namespace Drupal\contact\Plugin\views\field; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\LinkBase; use Drupal\views\ResultRow; @@ -11,9 +12,8 @@ use Drupal\views\ResultRow; * Defines a field that links to the user contact page, if access is permitted. * * @ingroup views_field_handlers - * - * @ViewsField("contact_link") */ +#[ViewsField("contact_link")] class ContactLink extends LinkBase { /** diff --git a/core/modules/content_moderation/src/Plugin/views/field/ModerationStateField.php b/core/modules/content_moderation/src/Plugin/views/field/ModerationStateField.php index 42a477c296a..4b4eea76b68 100644 --- a/core/modules/content_moderation/src/Plugin/views/field/ModerationStateField.php +++ b/core/modules/content_moderation/src/Plugin/views/field/ModerationStateField.php @@ -3,15 +3,15 @@ namespace Drupal\content_moderation\Plugin\views\field; use Drupal\content_moderation\Plugin\views\ModerationStateJoinViewsHandlerTrait; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\EntityField; /** * A field handler for the computed moderation_state field. * * @ingroup views_field_handlers - * - * @ViewsField("moderation_state_field") */ +#[ViewsField("moderation_state_field")] class ModerationStateField extends EntityField { use ModerationStateJoinViewsHandlerTrait; diff --git a/core/modules/content_translation/src/Plugin/views/field/TranslationLink.php b/core/modules/content_translation/src/Plugin/views/field/TranslationLink.php index 69d675ebb1f..d52b81c748c 100644 --- a/core/modules/content_translation/src/Plugin/views/field/TranslationLink.php +++ b/core/modules/content_translation/src/Plugin/views/field/TranslationLink.php @@ -2,15 +2,15 @@ namespace Drupal\content_translation\Plugin\views\field; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\EntityLink; /** * Provides a translation link for an entity. * * @ingroup views_field_handlers - * - * @ViewsField("content_translation_link") */ +#[ViewsField("content_translation_link")] class TranslationLink extends EntityLink { /** diff --git a/core/modules/contextual/src/Plugin/views/field/ContextualLinks.php b/core/modules/contextual/src/Plugin/views/field/ContextualLinks.php index 338d5d704fc..a7308729917 100644 --- a/core/modules/contextual/src/Plugin/views/field/ContextualLinks.php +++ b/core/modules/contextual/src/Plugin/views/field/ContextualLinks.php @@ -8,6 +8,7 @@ use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RedirectDestinationTrait; use Drupal\Core\Url; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\ResultRow; @@ -15,9 +16,8 @@ use Drupal\views\ResultRow; * Provides a handler that adds contextual links. * * @ingroup views_field_handlers - * - * @ViewsField("contextual_links") */ +#[ViewsField("contextual_links")] class ContextualLinks extends FieldPluginBase { use RedirectDestinationTrait; diff --git a/core/modules/dblog/src/Plugin/views/field/DblogMessage.php b/core/modules/dblog/src/Plugin/views/field/DblogMessage.php index fd18779f046..5e80ea68f55 100644 --- a/core/modules/dblog/src/Plugin/views/field/DblogMessage.php +++ b/core/modules/dblog/src/Plugin/views/field/DblogMessage.php @@ -4,6 +4,7 @@ namespace Drupal\dblog\Plugin\views\field; use Drupal\Component\Render\FormattableMarkup; use Drupal\Core\Form\FormStateInterface; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\ResultRow; use Drupal\views\ViewExecutable; @@ -13,9 +14,8 @@ use Drupal\views\Plugin\views\display\DisplayPluginBase; * Provides a field handler that renders a log event with replaced variables. * * @ingroup views_field_handlers - * - * @ViewsField("dblog_message") */ +#[ViewsField("dblog_message")] class DblogMessage extends FieldPluginBase { /** diff --git a/core/modules/dblog/src/Plugin/views/field/DblogOperations.php b/core/modules/dblog/src/Plugin/views/field/DblogOperations.php index 49a47fda814..15fc0833746 100644 --- a/core/modules/dblog/src/Plugin/views/field/DblogOperations.php +++ b/core/modules/dblog/src/Plugin/views/field/DblogOperations.php @@ -2,6 +2,7 @@ namespace Drupal\dblog\Plugin\views\field; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\ResultRow; @@ -9,9 +10,8 @@ use Drupal\views\ResultRow; * Provides a field handler that renders operation link markup. * * @ingroup views_field_handlers - * - * @ViewsField("dblog_operations") */ +#[ViewsField("dblog_operations")] class DblogOperations extends FieldPluginBase { /** diff --git a/core/modules/file/src/Plugin/views/field/File.php b/core/modules/file/src/Plugin/views/field/File.php index e00d50d9cfa..1002880d5fd 100644 --- a/core/modules/file/src/Plugin/views/field/File.php +++ b/core/modules/file/src/Plugin/views/field/File.php @@ -4,6 +4,7 @@ namespace Drupal\file\Plugin\views\field; use Drupal\Core\File\FileUrlGeneratorInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\views\Attribute\ViewsField; use Drupal\views\ResultRow; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -14,9 +15,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * Field handler to provide simple renderer that allows linking to a file. * * @ingroup views_field_handlers - * - * @ViewsField("file") */ +#[ViewsField("file")] class File extends FieldPluginBase { /** diff --git a/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php b/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php index 617cd23e12d..5af925479d2 100644 --- a/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php +++ b/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php @@ -3,6 +3,7 @@ namespace Drupal\history\Plugin\views\field; use Drupal\Core\Form\FormStateInterface; +use Drupal\views\Attribute\ViewsField; use Drupal\views\ResultRow; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -15,9 +16,8 @@ use Drupal\node\Plugin\views\field\Node; * table is history. * * @ingroup views_field_handlers - * - * @ViewsField("history_user_timestamp") */ +#[ViewsField("history_user_timestamp")] class HistoryUserTimestamp extends Node { /** diff --git a/core/modules/media_library/src/Plugin/views/field/MediaLibrarySelectForm.php b/core/modules/media_library/src/Plugin/views/field/MediaLibrarySelectForm.php index 64218f6345c..203d1cda890 100644 --- a/core/modules/media_library/src/Plugin/views/field/MediaLibrarySelectForm.php +++ b/core/modules/media_library/src/Plugin/views/field/MediaLibrarySelectForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Form\FormBuilderInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Drupal\media_library\MediaLibraryState; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Render\ViewsRenderPipelineMarkup; use Drupal\views\ResultRow; @@ -17,11 +18,10 @@ use Symfony\Component\HttpFoundation\Request; /** * Defines a field that outputs a checkbox and form for selecting media. * - * @ViewsField("media_library_select_form") - * * @internal * Plugin classes are internal. */ +#[ViewsField("media_library_select_form")] class MediaLibrarySelectForm extends FieldPluginBase { /** diff --git a/core/modules/node/src/Plugin/views/field/Node.php b/core/modules/node/src/Plugin/views/field/Node.php index 94cb1a24419..2ab90944f64 100644 --- a/core/modules/node/src/Plugin/views/field/Node.php +++ b/core/modules/node/src/Plugin/views/field/Node.php @@ -4,6 +4,7 @@ namespace Drupal\node\Plugin\views\field; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; +use Drupal\views\Attribute\ViewsField; use Drupal\views\ResultRow; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -17,9 +18,8 @@ use Drupal\views\Plugin\views\field\FieldPluginBase; * enabled by default. * * @ingroup views_field_handlers - * - * @ViewsField("node") */ +#[ViewsField("node")] class Node extends FieldPluginBase { /** diff --git a/core/modules/node/src/Plugin/views/field/NodeBulkForm.php b/core/modules/node/src/Plugin/views/field/NodeBulkForm.php index 4a6e219cceb..aa205b7b2c4 100644 --- a/core/modules/node/src/Plugin/views/field/NodeBulkForm.php +++ b/core/modules/node/src/Plugin/views/field/NodeBulkForm.php @@ -2,13 +2,13 @@ namespace Drupal\node\Plugin\views\field; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\BulkForm; /** * Defines a node operations bulk form element. - * - * @ViewsField("node_bulk_form") */ +#[ViewsField("node_bulk_form")] class NodeBulkForm extends BulkForm { /** diff --git a/core/modules/node/src/Plugin/views/field/RevisionLink.php b/core/modules/node/src/Plugin/views/field/RevisionLink.php index b1b981c607c..4fa2a08a9ae 100644 --- a/core/modules/node/src/Plugin/views/field/RevisionLink.php +++ b/core/modules/node/src/Plugin/views/field/RevisionLink.php @@ -3,6 +3,7 @@ namespace Drupal\node\Plugin\views\field; use Drupal\Core\Url; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\LinkBase; use Drupal\views\ResultRow; @@ -10,9 +11,8 @@ use Drupal\views\ResultRow; * Field handler to present a link to a node revision. * * @ingroup views_field_handlers - * - * @ViewsField("node_revision_link") */ +#[ViewsField("node_revision_link")] class RevisionLink extends LinkBase { /** diff --git a/core/modules/node/src/Plugin/views/field/RevisionLinkDelete.php b/core/modules/node/src/Plugin/views/field/RevisionLinkDelete.php index 8f92a2ee1b9..89d91783e17 100644 --- a/core/modules/node/src/Plugin/views/field/RevisionLinkDelete.php +++ b/core/modules/node/src/Plugin/views/field/RevisionLinkDelete.php @@ -3,15 +3,15 @@ namespace Drupal\node\Plugin\views\field; use Drupal\Core\Url; +use Drupal\views\Attribute\ViewsField; use Drupal\views\ResultRow; /** * Field handler to present link to delete a node revision. * * @ingroup views_field_handlers - * - * @ViewsField("node_revision_link_delete") */ +#[ViewsField("node_revision_link_delete")] class RevisionLinkDelete extends RevisionLink { /** diff --git a/core/modules/node/src/Plugin/views/field/RevisionLinkRevert.php b/core/modules/node/src/Plugin/views/field/RevisionLinkRevert.php index 7c6c10f8b3c..de53dc2d1a8 100644 --- a/core/modules/node/src/Plugin/views/field/RevisionLinkRevert.php +++ b/core/modules/node/src/Plugin/views/field/RevisionLinkRevert.php @@ -3,15 +3,15 @@ namespace Drupal\node\Plugin\views\field; use Drupal\Core\Url; +use Drupal\views\Attribute\ViewsField; use Drupal\views\ResultRow; /** * Field handler to present a link to revert a node to a revision. * * @ingroup views_field_handlers - * - * @ViewsField("node_revision_link_revert") */ +#[ViewsField("node_revision_link_revert")] class RevisionLinkRevert extends RevisionLink { /** diff --git a/core/modules/search/src/Plugin/views/field/Score.php b/core/modules/search/src/Plugin/views/field/Score.php index 643fcc45d4b..453acac6d00 100644 --- a/core/modules/search/src/Plugin/views/field/Score.php +++ b/core/modules/search/src/Plugin/views/field/Score.php @@ -2,6 +2,7 @@ namespace Drupal\search\Plugin\views\field; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\NumericField; use Drupal\views\ResultRow; @@ -9,9 +10,8 @@ use Drupal\views\ResultRow; * Field handler for search score. * * @ingroup views_field_handlers - * - * @ViewsField("search_score") */ +#[ViewsField("search_score")] class Score extends NumericField { /** diff --git a/core/modules/statistics/src/Plugin/views/field/NodeCounterTimestamp.php b/core/modules/statistics/src/Plugin/views/field/NodeCounterTimestamp.php index fb0eb3049e5..39dcc0150ec 100644 --- a/core/modules/statistics/src/Plugin/views/field/NodeCounterTimestamp.php +++ b/core/modules/statistics/src/Plugin/views/field/NodeCounterTimestamp.php @@ -2,6 +2,7 @@ namespace Drupal\statistics\Plugin\views\field; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\Date; use Drupal\Core\Session\AccountInterface; @@ -9,9 +10,8 @@ use Drupal\Core\Session\AccountInterface; * Field handler to display the most recent time the node has been viewed. * * @ingroup views_field_handlers - * - * @ViewsField("node_counter_timestamp") */ +#[ViewsField("node_counter_timestamp")] class NodeCounterTimestamp extends Date { /** diff --git a/core/modules/statistics/src/Plugin/views/field/StatisticsNumeric.php b/core/modules/statistics/src/Plugin/views/field/StatisticsNumeric.php index a425b31184b..73c9092cd6a 100644 --- a/core/modules/statistics/src/Plugin/views/field/StatisticsNumeric.php +++ b/core/modules/statistics/src/Plugin/views/field/StatisticsNumeric.php @@ -2,6 +2,7 @@ namespace Drupal\statistics\Plugin\views\field; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\NumericField; use Drupal\Core\Session\AccountInterface; @@ -9,9 +10,8 @@ use Drupal\Core\Session\AccountInterface; * Field handler to display numeric values from the statistics module. * * @ingroup views_field_handlers - * - * @ViewsField("statistics_numeric") */ +#[ViewsField("statistics_numeric")] class StatisticsNumeric extends NumericField { /** diff --git a/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php index dc145a0e0fc..c1a3c4fa082 100644 --- a/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php +++ b/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php @@ -3,6 +3,7 @@ namespace Drupal\taxonomy\Plugin\views\field; use Drupal\Core\Form\FormStateInterface; +use Drupal\views\Attribute\ViewsField; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\field\PrerenderList; @@ -13,9 +14,8 @@ use Drupal\taxonomy\VocabularyStorageInterface; * Field handler to display all taxonomy terms of a node. * * @ingroup views_field_handlers - * - * @ViewsField("taxonomy_index_tid") */ +#[ViewsField("taxonomy_index_tid")] class TaxonomyIndexTid extends PrerenderList { /** diff --git a/core/modules/taxonomy/src/Plugin/views/field/TermName.php b/core/modules/taxonomy/src/Plugin/views/field/TermName.php index 18c7f353b88..5f14a042891 100644 --- a/core/modules/taxonomy/src/Plugin/views/field/TermName.php +++ b/core/modules/taxonomy/src/Plugin/views/field/TermName.php @@ -3,6 +3,7 @@ namespace Drupal\taxonomy\Plugin\views\field; use Drupal\Core\Form\FormStateInterface; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\EntityField; use Drupal\views\ResultRow; @@ -10,9 +11,8 @@ use Drupal\views\ResultRow; * Displays taxonomy term names and allows converting spaces to hyphens. * * @ingroup views_field_handlers - * - * @ViewsField("term_name") */ +#[ViewsField("term_name")] class TermName extends EntityField { /** diff --git a/core/modules/user/src/Plugin/views/field/Permissions.php b/core/modules/user/src/Plugin/views/field/Permissions.php index c9b29a6e2d5..cad795c7fa5 100644 --- a/core/modules/user/src/Plugin/views/field/Permissions.php +++ b/core/modules/user/src/Plugin/views/field/Permissions.php @@ -4,6 +4,7 @@ namespace Drupal\user\Plugin\views\field; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\field\PrerenderList; @@ -13,9 +14,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * Field handler to provide a list of permissions. * * @ingroup views_field_handlers - * - * @ViewsField("user_permissions") */ +#[ViewsField("user_permissions")] class Permissions extends PrerenderList { /** diff --git a/core/modules/user/src/Plugin/views/field/Roles.php b/core/modules/user/src/Plugin/views/field/Roles.php index 2c7a7b00bd7..45124cd0f2a 100644 --- a/core/modules/user/src/Plugin/views/field/Roles.php +++ b/core/modules/user/src/Plugin/views/field/Roles.php @@ -3,6 +3,7 @@ namespace Drupal\user\Plugin\views\field; use Drupal\Core\Database\Connection; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\field\PrerenderList; @@ -13,9 +14,8 @@ use Drupal\user\Entity\Role; * Field handler to provide a list of roles. * * @ingroup views_field_handlers - * - * @ViewsField("user_roles") */ +#[ViewsField("user_roles")] class Roles extends PrerenderList { /** diff --git a/core/modules/user/src/Plugin/views/field/UserBulkForm.php b/core/modules/user/src/Plugin/views/field/UserBulkForm.php index 805df2b9e43..457a7a10d4f 100644 --- a/core/modules/user/src/Plugin/views/field/UserBulkForm.php +++ b/core/modules/user/src/Plugin/views/field/UserBulkForm.php @@ -4,13 +4,13 @@ namespace Drupal\user\Plugin\views\field; use Drupal\Core\Form\FormStateInterface; use Drupal\user\UserInterface; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\BulkForm; /** * Defines a user operations bulk form element. - * - * @ViewsField("user_bulk_form") */ +#[ViewsField("user_bulk_form")] class UserBulkForm extends BulkForm { /** diff --git a/core/modules/user/src/Plugin/views/field/UserData.php b/core/modules/user/src/Plugin/views/field/UserData.php index fb853cfc0a3..65743564b23 100644 --- a/core/modules/user/src/Plugin/views/field/UserData.php +++ b/core/modules/user/src/Plugin/views/field/UserData.php @@ -5,6 +5,7 @@ namespace Drupal\user\Plugin\views\field; use Drupal\Core\Extension\ModuleExtensionList; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\ResultRow; use Drupal\user\UserDataInterface; @@ -16,9 +17,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * @ingroup views_field_handlers * * @see \Drupal\user\UserDataInterface - * - * @ViewsField("user_data") */ +#[ViewsField("user_data")] class UserData extends FieldPluginBase { /** diff --git a/core/modules/views/src/Attribute/ViewsField.php b/core/modules/views/src/Attribute/ViewsField.php new file mode 100644 index 00000000000..ff1387a0516 --- /dev/null +++ b/core/modules/views/src/Attribute/ViewsField.php @@ -0,0 +1,19 @@ +