diff --git a/templates/Plugin/Views/_field/field.twig b/templates/Plugin/Views/_field/field.twig index ad9a59f12..5b6dd9105 100644 --- a/templates/Plugin/Views/_field/field.twig +++ b/templates/Plugin/Views/_field/field.twig @@ -7,6 +7,7 @@ namespace Drupal\{{ machine_name }}\Plugin\views\field; {% apply sort_namespaces %} use Drupal\Component\Render\MarkupInterface; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\ResultRow; {% if configurable %} @@ -21,8 +22,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides {{ plugin_label }} field handler. * - * @ViewsField("{{ plugin_id }}") - * * @DCG * The plugin needs to be assigned to a specific table column through * hook_views_data() or hook_views_data_alter(). @@ -37,6 +36,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * } * @endcode */ +#[ViewsField('{{ plugin_id }}')] final class {{ class }} extends FieldPluginBase { {% if services %} diff --git a/tests/functional/Generator/Plugin/Views/_field/_n_deps/_n_config/src/Plugin/views/field/Example.php b/tests/functional/Generator/Plugin/Views/_field/_n_deps/_n_config/src/Plugin/views/field/Example.php index fdd6ce311..c5e8e4e16 100644 --- a/tests/functional/Generator/Plugin/Views/_field/_n_deps/_n_config/src/Plugin/views/field/Example.php +++ b/tests/functional/Generator/Plugin/Views/_field/_n_deps/_n_config/src/Plugin/views/field/Example.php @@ -5,14 +5,13 @@ namespace Drupal\foo\Plugin\views\field; use Drupal\Component\Render\MarkupInterface; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\ResultRow; /** * Provides Example field handler. * - * @ViewsField("foo_example") - * * @DCG * The plugin needs to be assigned to a specific table column through * hook_views_data() or hook_views_data_alter(). @@ -27,6 +26,7 @@ * } * @endcode */ +#[ViewsField('foo_example')] final class Example extends FieldPluginBase { /** diff --git a/tests/functional/Generator/Plugin/Views/_field/_w_deps/_w_config/src/Plugin/views/field/Example.php b/tests/functional/Generator/Plugin/Views/_field/_w_deps/_w_config/src/Plugin/views/field/Example.php index 00e30414d..8dd8d09ad 100644 --- a/tests/functional/Generator/Plugin/Views/_field/_w_deps/_w_config/src/Plugin/views/field/Example.php +++ b/tests/functional/Generator/Plugin/Views/_field/_w_deps/_w_config/src/Plugin/views/field/Example.php @@ -7,6 +7,7 @@ use Drupal\Component\Render\MarkupInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\ResultRow; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -14,8 +15,6 @@ /** * Provides Example field handler. * - * @ViewsField("foo_example") - * * @DCG * The plugin needs to be assigned to a specific table column through * hook_views_data() or hook_views_data_alter(). @@ -30,6 +29,7 @@ * } * @endcode */ +#[ViewsField('foo_example')] final class Example extends FieldPluginBase { /**