Skip to content

Commit

Permalink
Merge pull request #169 from Chi-teck/php-attribute-views-argument-de…
Browse files Browse the repository at this point in the history
…fault

Use PHP attribute for ViewsArgumentDefault plugin
  • Loading branch information
Chi-teck authored May 24, 2024
2 parents a0dd0ad + ca5a167 commit 9efe42a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions templates/Plugin/Views/_argument-default/argument-default.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace Drupal\{{ machine_name }}\Plugin\views\argument_default;
{% apply sort_namespaces %}
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\views\Attribute\ViewsArgumentDefault;
{% if configurable %}
use Drupal\Core\Form\FormStateInterface;
{% endif %}
Expand All @@ -20,12 +22,11 @@ use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* @todo Add plugin description here.
*
* @ViewsArgumentDefault(
* id = "{{ plugin_id }}",
* title = @Translation("{{ plugin_label }}"),
* )
*/
#[ViewsArgumentDefault(
id: '{{ plugin_id }}',
title: new TranslatableMarkup('{{ plugin_label }}'),
)]
final class {{ class }} extends ArgumentDefaultPluginBase implements CacheableDependencyInterface {

{% if services %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\views\Attribute\ViewsArgumentDefault;
use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* @todo Add plugin description here.
*
* @ViewsArgumentDefault(
* id = "foo_example",
* title = @Translation("Example"),
* )
*/
#[ViewsArgumentDefault(
id: 'foo_example',
title: new TranslatableMarkup('Example'),
)]
final class Example extends ArgumentDefaultPluginBase implements CacheableDependencyInterface {

/**
Expand Down

0 comments on commit 9efe42a

Please sign in to comment.