diff --git a/core/modules/block_content/src/Plugin/views/wizard/BlockContent.php b/core/modules/block_content/src/Plugin/views/wizard/BlockContent.php index cb19c6247dcf530073b679b5a91b0e3411de6d49..eb2de7e50c2ac7d613af1e7cc5a898e5ec688204 100644 --- a/core/modules/block_content/src/Plugin/views/wizard/BlockContent.php +++ b/core/modules/block_content/src/Plugin/views/wizard/BlockContent.php @@ -2,17 +2,18 @@ namespace Drupal\block_content\Plugin\views\wizard; +use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\views\Attribute\ViewsWizard; use Drupal\views\Plugin\views\wizard\WizardPluginBase; /** * Used for creating 'block_content' views with the wizard. - * - * @ViewsWizard( - * id = "block_content", - * base_table = "block_content_field_data", - * title = @Translation("Content Block"), - * ) */ +#[ViewsWizard( + id: 'block_content', + title: new TranslatableMarkup('Content Block'), + base_table: 'block_content_field_data' +)] class BlockContent extends WizardPluginBase { /** diff --git a/core/modules/comment/src/Plugin/views/wizard/Comment.php b/core/modules/comment/src/Plugin/views/wizard/Comment.php index 7cc5c632cc05b0ae1d3b8b335b444978e9ba96c3..3e662475b401b77b62548b9239c5dad37bb7de78 100644 --- a/core/modules/comment/src/Plugin/views/wizard/Comment.php +++ b/core/modules/comment/src/Plugin/views/wizard/Comment.php @@ -2,6 +2,8 @@ namespace Drupal\comment\Plugin\views\wizard; +use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\views\Attribute\ViewsWizard; use Drupal\views\Plugin\views\wizard\WizardPluginBase; /** @@ -10,13 +12,12 @@ /** * Tests creating comment views with the wizard. - * - * @ViewsWizard( - * id = "comment", - * base_table = "comment_field_data", - * title = @Translation("Comments") - * ) */ +#[ViewsWizard( + id: 'comment', + base_table: 'comment_field_data', + title: new TranslatableMarkup('Comments') +)] class Comment extends WizardPluginBase { /** diff --git a/core/modules/dblog/src/Plugin/views/wizard/Watchdog.php b/core/modules/dblog/src/Plugin/views/wizard/Watchdog.php index 3a0dad5c86dd92a40dbdbf165a761fb86193c427..ac78fe828bcc79a6e68320e22b1b8ddc311c599a 100644 --- a/core/modules/dblog/src/Plugin/views/wizard/Watchdog.php +++ b/core/modules/dblog/src/Plugin/views/wizard/Watchdog.php @@ -2,18 +2,18 @@ namespace Drupal\dblog\Plugin\views\wizard; +use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\views\Attribute\ViewsWizard; use Drupal\views\Plugin\views\wizard\WizardPluginBase; /** * Defines a wizard for the watchdog table. - * - * @ViewsWizard( - * id = "watchdog", - * module = "dblog", - * base_table = "watchdog", - * title = @Translation("Log entries") - * ) */ +#[ViewsWizard( + id: 'watchdog', + title: new TranslatableMarkup('Log entries'), + base_table: 'watchdog' +)] class Watchdog extends WizardPluginBase { /** diff --git a/core/modules/file/src/Plugin/views/wizard/File.php b/core/modules/file/src/Plugin/views/wizard/File.php index f870f6576a06009c2fd7218643d186841d7822eb..2d1d8a5cf38266a964805e2f9e08ab30829c3549 100644 --- a/core/modules/file/src/Plugin/views/wizard/File.php +++ b/core/modules/file/src/Plugin/views/wizard/File.php @@ -2,17 +2,18 @@ namespace Drupal\file\Plugin\views\wizard; +use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\views\Attribute\ViewsWizard; use Drupal\views\Plugin\views\wizard\WizardPluginBase; /** * Tests creating managed files views with the wizard. - * - * @ViewsWizard( - * id = "file_managed", - * base_table = "file_managed", - * title = @Translation("Files") - * ) */ +#[ViewsWizard( + id: 'file_managed', + title: new TranslatableMarkup('Files'), + base_table: 'file_managed' +)] class File extends WizardPluginBase { /** diff --git a/core/modules/media/src/Plugin/views/wizard/Media.php b/core/modules/media/src/Plugin/views/wizard/Media.php index 30a7ad632381cbbdc2befe17d492fc3211465b23..322f04fc2885d2a59577bdfce798dc55a8ffdf96 100644 --- a/core/modules/media/src/Plugin/views/wizard/Media.php +++ b/core/modules/media/src/Plugin/views/wizard/Media.php @@ -2,17 +2,18 @@ namespace Drupal\media\Plugin\views\wizard; +use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\views\Attribute\ViewsWizard; use Drupal\views\Plugin\views\wizard\WizardPluginBase; /** * Provides Views creation wizard for Media. - * - * @ViewsWizard( - * id = "media", - * base_table = "media_field_data", - * title = @Translation("Media") - * ) */ +#[ViewsWizard( + id: 'media', + base_table: 'media_field_data', + title: new TranslatableMarkup('Media') +)] class Media extends WizardPluginBase { /** diff --git a/core/modules/media/src/Plugin/views/wizard/MediaRevision.php b/core/modules/media/src/Plugin/views/wizard/MediaRevision.php index 10b51547b9d471cd12cc58f6c45cee02e8e3d8ad..f7a2aafee23ee8e86aadaa7a5bfe98d3b2d431e6 100644 --- a/core/modules/media/src/Plugin/views/wizard/MediaRevision.php +++ b/core/modules/media/src/Plugin/views/wizard/MediaRevision.php @@ -2,17 +2,18 @@ namespace Drupal\media\Plugin\views\wizard; +use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\views\Attribute\ViewsWizard; use Drupal\views\Plugin\views\wizard\WizardPluginBase; /** * Provides Views creation wizard for Media revisions. - * - * @ViewsWizard( - * id = "media_revision", - * base_table = "media_field_revision", - * title = @Translation("Media revisions") - * ) */ +#[ViewsWizard( + id: 'media_revision', + title: new TranslatableMarkup('Media revisions'), + base_table: 'media_field_revision' +)] class MediaRevision extends WizardPluginBase { /** diff --git a/core/modules/node/src/Plugin/views/wizard/Node.php b/core/modules/node/src/Plugin/views/wizard/Node.php index ea00810862354f2a65420e1a264699d830cf65b6..6e2ca1d1f2d69ef9017b279a1dc56edb7c47f4ca 100644 --- a/core/modules/node/src/Plugin/views/wizard/Node.php +++ b/core/modules/node/src/Plugin/views/wizard/Node.php @@ -8,6 +8,8 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Menu\MenuParentFormSelectorInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\views\Attribute\ViewsWizard; use Drupal\views\Plugin\views\wizard\WizardPluginBase; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -17,13 +19,12 @@ /** * Tests creating node views with the wizard. - * - * @ViewsWizard( - * id = "node", - * base_table = "node_field_data", - * title = @Translation("Content") - * ) */ +#[ViewsWizard( + id: 'node', + base_table: 'node_field_data', + title: new TranslatableMarkup('Content') +)] class Node extends WizardPluginBase { /** diff --git a/core/modules/node/src/Plugin/views/wizard/NodeRevision.php b/core/modules/node/src/Plugin/views/wizard/NodeRevision.php index 14119d4fb56587c2f289bd1f60127caf5a26be7d..1a7121eb007a847cdc8a2281d5810435620fdf39 100644 --- a/core/modules/node/src/Plugin/views/wizard/NodeRevision.php +++ b/core/modules/node/src/Plugin/views/wizard/NodeRevision.php @@ -3,6 +3,8 @@ namespace Drupal\node\Plugin\views\wizard; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\views\Attribute\ViewsWizard; use Drupal\views\Plugin\views\wizard\WizardPluginBase; /** @@ -11,13 +13,12 @@ /** * Tests creating node revision views with the wizard. - * - * @ViewsWizard( - * id = "node_revision", - * base_table = "node_field_revision", - * title = @Translation("Content revisions") - * ) */ +#[ViewsWizard( + id: 'node_revision', + title: new TranslatableMarkup('Content revisions'), + base_table: 'node_field_revision' +)] class NodeRevision extends WizardPluginBase { /** diff --git a/core/modules/taxonomy/src/Plugin/views/wizard/TaxonomyTerm.php b/core/modules/taxonomy/src/Plugin/views/wizard/TaxonomyTerm.php index cc79681093d468bcb3693c414d9edfa066a3cd94..751f365c493e1acf153a4e3de265339356fd75ee 100644 --- a/core/modules/taxonomy/src/Plugin/views/wizard/TaxonomyTerm.php +++ b/core/modules/taxonomy/src/Plugin/views/wizard/TaxonomyTerm.php @@ -2,17 +2,18 @@ namespace Drupal\taxonomy\Plugin\views\wizard; +use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\views\Attribute\ViewsWizard; use Drupal\views\Plugin\views\wizard\WizardPluginBase; /** * Tests creating taxonomy views with the wizard. - * - * @ViewsWizard( - * id = "taxonomy_term", - * base_table = "taxonomy_term_field_data", - * title = @Translation("Taxonomy terms") - * ) */ +#[ViewsWizard( + id: 'taxonomy_term', + title: new TranslatableMarkup('Taxonomy terms'), + base_table: 'taxonomy_term_field_data' +)] class TaxonomyTerm extends WizardPluginBase { /** diff --git a/core/modules/user/src/Plugin/views/wizard/Users.php b/core/modules/user/src/Plugin/views/wizard/Users.php index 6ba045f70d990a5e439405ad906062d3d864bd1f..92b8f28d901c9c820f6ee98eff4569cdd218065c 100644 --- a/core/modules/user/src/Plugin/views/wizard/Users.php +++ b/core/modules/user/src/Plugin/views/wizard/Users.php @@ -2,6 +2,8 @@ namespace Drupal\user\Plugin\views\wizard; +use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\views\Attribute\ViewsWizard; use Drupal\views\Plugin\views\wizard\WizardPluginBase; /** @@ -10,13 +12,12 @@ /** * Tests creating user views with the wizard. - * - * @ViewsWizard( - * id = "users", - * base_table = "users_field_data", - * title = @Translation("Users") - * ) */ +#[ViewsWizard( + id: 'users', + title: new TranslatableMarkup('Users'), + base_table: 'users_field_data' +)] class Users extends WizardPluginBase { /** diff --git a/core/modules/views/src/Attribute/ViewsWizard.php b/core/modules/views/src/Attribute/ViewsWizard.php new file mode 100644 index 0000000000000000000000000000000000000000..e5ef222bb07ba4c3e62d27121cfe5f21cd8d3bd8 --- /dev/null +++ b/core/modules/views/src/Attribute/ViewsWizard.php @@ -0,0 +1,39 @@ +<?php + +namespace Drupal\views\Attribute; + +use Drupal\Component\Plugin\Attribute\Plugin; +use Drupal\Core\StringTranslation\TranslatableMarkup; + +/** + * Defines a Plugin attribute object for views wizard plugins. + * + * @see \Drupal\views\Plugin\views\wizard\WizardPluginBase + * @see \Drupal\views\Plugin\views\wizard\WizardInterface + * + * @ingroup views_wizard_plugins + */ +#[\Attribute(\Attribute::TARGET_CLASS)] +class ViewsWizard extends Plugin { + + /** + * Constructs an ViewsWizard attribute. + * + * @param string $id + * The plugin ID. + * @param \Drupal\Core\StringTranslation\TranslatableMarkup $title + * The plugin title used in the views UI. + * @param string|null $base_table + * (optional) The base table on which this wizard is used. The base_table is + * required when a deriver class is not defined. + * @param class-string|null $deriver + * (optional) The deriver class. + */ + public function __construct( + public readonly string $id, + public readonly TranslatableMarkup $title, + public readonly ?string $base_table = NULL, + public readonly ?string $deriver = NULL + ) {} + +} diff --git a/core/modules/views/src/Plugin/views/wizard/Standard.php b/core/modules/views/src/Plugin/views/wizard/Standard.php index a277fbd1a223a9bc9be2a9d3fdf4c0eb9d83b707..30875ed7570d29bce84f5253ded6434d739b66c0 100644 --- a/core/modules/views/src/Plugin/views/wizard/Standard.php +++ b/core/modules/views/src/Plugin/views/wizard/Standard.php @@ -2,17 +2,20 @@ namespace Drupal\views\Plugin\views\wizard; +use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\views\Attribute\ViewsWizard; +use Drupal\views\Plugin\Derivative\DefaultWizardDeriver; + /** * Standard Views wizard plugin. * * @ingroup views_wizard_plugins - * - * @ViewsWizard( - * id = "standard", - * deriver = "Drupal\views\Plugin\Derivative\DefaultWizardDeriver", - * title = @Translation("Default wizard") - * ) */ +#[ViewsWizard( + id: 'standard', + title: new TranslatableMarkup('Default wizard'), + deriver: DefaultWizardDeriver::class, +)] class Standard extends WizardPluginBase { }