Skip to content

Commit 9efe42a

Browse files
authored
Merge pull request #169 from Chi-teck/php-attribute-views-argument-default
Use PHP attribute for ViewsArgumentDefault plugin
2 parents a0dd0ad + ca5a167 commit 9efe42a

File tree

2 files changed

+12
-10
lines changed
  • templates/Plugin/Views/_argument-default
  • tests/functional/Generator/Plugin/Views/_argument_default/src/Plugin/views/argument_default

2 files changed

+12
-10
lines changed

templates/Plugin/Views/_argument-default/argument-default.twig

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace Drupal\{{ machine_name }}\Plugin\views\argument_default;
88
{% apply sort_namespaces %}
99
use Drupal\Core\Cache\Cache;
1010
use Drupal\Core\Cache\CacheableDependencyInterface;
11+
use Drupal\Core\StringTranslation\TranslatableMarkup;
12+
use Drupal\views\Attribute\ViewsArgumentDefault;
1113
{% if configurable %}
1214
use Drupal\Core\Form\FormStateInterface;
1315
{% endif %}
@@ -20,12 +22,11 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
2022
2123
/**
2224
* @todo Add plugin description here.
23-
*
24-
* @ViewsArgumentDefault(
25-
* id = "{{ plugin_id }}",
26-
* title = @Translation("{{ plugin_label }}"),
27-
* )
2825
*/
26+
#[ViewsArgumentDefault(
27+
id: '{{ plugin_id }}',
28+
title: new TranslatableMarkup('{{ plugin_label }}'),
29+
)]
2930
final class {{ class }} extends ArgumentDefaultPluginBase implements CacheableDependencyInterface {
3031
3132
{% if services %}

tests/functional/Generator/Plugin/Views/_argument_default/src/Plugin/views/argument_default/Example.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@
88
use Drupal\Core\Cache\CacheableDependencyInterface;
99
use Drupal\Core\Form\FormStateInterface;
1010
use Drupal\Core\Routing\RouteMatchInterface;
11+
use Drupal\Core\StringTranslation\TranslatableMarkup;
12+
use Drupal\views\Attribute\ViewsArgumentDefault;
1113
use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase;
1214
use Symfony\Component\DependencyInjection\ContainerInterface;
1315

1416
/**
1517
* @todo Add plugin description here.
16-
*
17-
* @ViewsArgumentDefault(
18-
* id = "foo_example",
19-
* title = @Translation("Example"),
20-
* )
2118
*/
19+
#[ViewsArgumentDefault(
20+
id: 'foo_example',
21+
title: new TranslatableMarkup('Example'),
22+
)]
2223
final class Example extends ArgumentDefaultPluginBase implements CacheableDependencyInterface {
2324

2425
/**

0 commit comments

Comments
 (0)