diff --git a/core/modules/rest/src/Plugin/views/display/RestExport.php b/core/modules/rest/src/Plugin/views/display/RestExport.php index 063f983e547..cc9226c4e98 100644 --- a/core/modules/rest/src/Plugin/views/display/RestExport.php +++ b/core/modules/rest/src/Plugin/views/display/RestExport.php @@ -10,6 +10,8 @@ use Drupal\Core\Render\RenderContext; use Drupal\Core\Render\RendererInterface; use Drupal\Core\Routing\RouteProviderInterface; use Drupal\Core\State\StateInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\views\Attribute\ViewsDisplay; use Drupal\views\Plugin\views\display\ResponseDisplayPluginInterface; use Drupal\views\Render\ViewsRenderPipelineMarkup; use Drupal\views\ViewExecutable; @@ -22,16 +24,15 @@ use Symfony\Component\Routing\RouteCollection; * The plugin that handles Data response callbacks for REST resources. * * @ingroup views_display_plugins - * - * @ViewsDisplay( - * id = "rest_export", - * title = @Translation("REST export"), - * help = @Translation("Create a REST export resource."), - * uses_route = TRUE, - * admin = @Translation("REST export"), - * returns_response = TRUE - * ) */ +#[ViewsDisplay( + id: "rest_export", + title: new TranslatableMarkup("REST export"), + help: new TranslatableMarkup("Create a REST export resource."), + admin: new TranslatableMarkup("REST export"), + uses_route: TRUE, + returns_response: TRUE +)] class RestExport extends PathPluginBase implements ResponseDisplayPluginInterface { /** diff --git a/core/modules/views/src/Attribute/ViewsDisplay.php b/core/modules/views/src/Attribute/ViewsDisplay.php new file mode 100644 index 00000000000..27e9cfe7caa --- /dev/null +++ b/core/modules/views/src/Attribute/ViewsDisplay.php @@ -0,0 +1,89 @@ + !\Drupal::config('views.settings')->get('ui.show.display_embed'), - * - * @ViewsDisplay( - * id = "embed", - * title = @Translation("Embed"), - * help = @Translation("Provide a display which can be embedded using the views api."), - * theme = "views_view", - * uses_menu_links = FALSE - * ) */ +#[ViewsDisplay( + id: "embed", + title: new TranslatableMarkup("Embed"), + help: new TranslatableMarkup("Provide a display which can be embedded using the views api."), + theme: "views_view", + uses_menu_links: FALSE +)] class Embed extends DisplayPluginBase { /** diff --git a/core/modules/views/src/Plugin/views/display/EntityReference.php b/core/modules/views/src/Plugin/views/display/EntityReference.php index d81ff34db21..ed9a7325e78 100644 --- a/core/modules/views/src/Plugin/views/display/EntityReference.php +++ b/core/modules/views/src/Plugin/views/display/EntityReference.php @@ -3,6 +3,8 @@ namespace Drupal\views\Plugin\views\display; use Drupal\Core\Database\Connection; +use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\views\Attribute\ViewsDisplay; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -13,18 +15,17 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * 'Entity Reference' display. * * @ingroup views_display_plugins - * - * @ViewsDisplay( - * id = "entity_reference", - * title = @Translation("Entity Reference"), - * admin = @Translation("Entity Reference Source"), - * help = @Translation("Selects referenceable entities for an entity reference field."), - * theme = "views_view", - * register_theme = FALSE, - * uses_menu_links = FALSE, - * entity_reference_display = TRUE - * ) */ +#[ViewsDisplay( + id: "entity_reference", + title: new TranslatableMarkup("Entity Reference"), + admin: new TranslatableMarkup("Entity Reference Source"), + help: new TranslatableMarkup("Selects referenceable entities for an entity reference field."), + theme: "views_view", + register_theme: FALSE, + uses_menu_links: FALSE, + entity_reference_display: TRUE +)] class EntityReference extends DisplayPluginBase { /** diff --git a/core/modules/views/src/Plugin/views/display/Feed.php b/core/modules/views/src/Plugin/views/display/Feed.php index caf6f8cbc92..024458b45b6 100644 --- a/core/modules/views/src/Plugin/views/display/Feed.php +++ b/core/modules/views/src/Plugin/views/display/Feed.php @@ -8,6 +8,8 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\RendererInterface; use Drupal\Core\Routing\RouteProviderInterface; use Drupal\Core\State\StateInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\views\Attribute\ViewsDisplay; use Drupal\views\ViewExecutable; use Drupal\views\Views; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -17,16 +19,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * The plugin that handles a feed, such as RSS or atom. * * @ingroup views_display_plugins - * - * @ViewsDisplay( - * id = "feed", - * title = @Translation("Feed"), - * help = @Translation("Display the view as a feed, such as an RSS feed."), - * uses_route = TRUE, - * admin = @Translation("Feed"), - * returns_response = TRUE - * ) */ +#[ViewsDisplay( + id: "feed", + title: new TranslatableMarkup("Feed"), + admin: new TranslatableMarkup("Feed"), + help: new TranslatableMarkup("Display the view as a feed, such as an RSS feed."), + uses_route: TRUE, + returns_response: TRUE +)] class Feed extends PathPluginBase implements ResponseDisplayPluginInterface { /** diff --git a/core/modules/views/src/Plugin/views/display/Page.php b/core/modules/views/src/Plugin/views/display/Page.php index bf0286ffa6c..504a589cec6 100644 --- a/core/modules/views/src/Plugin/views/display/Page.php +++ b/core/modules/views/src/Plugin/views/display/Page.php @@ -9,6 +9,8 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Menu\MenuParentFormSelectorInterface; use Drupal\Core\State\StateInterface; use Drupal\Core\Routing\RouteProviderInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\views\Attribute\ViewsDisplay; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Routing\Route; @@ -16,18 +18,17 @@ use Symfony\Component\Routing\Route; * The plugin that handles a full page. * * @ingroup views_display_plugins - * - * @ViewsDisplay( - * id = "page", - * title = @Translation("Page"), - * help = @Translation("Display the view as a page, with a URL and menu links."), - * uses_menu_links = TRUE, - * uses_route = TRUE, - * contextual_links_locations = {"page"}, - * theme = "views_view", - * admin = @Translation("Page") - * ) */ +#[ViewsDisplay( + id: "page", + title: new TranslatableMarkup("Page"), + help: new TranslatableMarkup("Display the view as a page, with a URL and menu links."), + uses_menu_links: TRUE, + uses_route: TRUE, + contextual_links_locations: ["page"], + theme: "views_view", + admin: new TranslatableMarkup("Page"), +)] class Page extends PathPluginBase { /** diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayNoAreaTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayNoAreaTest.php index 61881b44645..8e9eacec686 100644 --- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayNoAreaTest.php +++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayNoAreaTest.php @@ -2,18 +2,20 @@ namespace Drupal\views_test_data\Plugin\views\display; +use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\views\Attribute\ViewsDisplay; + /** * Defines a Display test plugin with areas disabled. - * - * @ViewsDisplay( - * id = "display_no_area_test", - * title = @Translation("Display test no area"), - * help = @Translation("Defines a display test with areas disabled."), - * theme = "views_view", - * register_theme = FALSE, - * contextual_links_locations = {"view"} - * ) */ +#[ViewsDisplay( + id: "display_no_area_test", + title: new TranslatableMarkup("Display test no area"), + help: new TranslatableMarkup("Defines a display test with areas disabled."), + theme: "views_view", + register_theme: FALSE, + contextual_links_locations: ["view"] +)] class DisplayNoAreaTest extends DisplayTest { /** diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayTest.php index 3c4b41d5cd1..fe94f740de5 100644 --- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayTest.php +++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayTest.php @@ -5,20 +5,21 @@ namespace Drupal\views_test_data\Plugin\views\display; use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\Xss; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\views\Attribute\ViewsDisplay; use Drupal\views\Plugin\views\display\DisplayPluginBase; /** * Defines a Display test plugin. - * - * @ViewsDisplay( - * id = "display_test", - * title = @Translation("Display test"), - * help = @Translation("Defines a display test plugin."), - * theme = "views_view", - * register_theme = FALSE, - * contextual_links_locations = {"view"} - * ) */ +#[ViewsDisplay( + id: "display_test", + title: new TranslatableMarkup("Display test"), + help: new TranslatableMarkup("Defines a display test plugin."), + theme: "views_view", + register_theme: FALSE, + contextual_links_locations: ["view"] +)] class DisplayTest extends DisplayPluginBase { /**