Skip to content

Commit

Permalink
Merge pull request #168 from Chi-teck/php-attribute-views-field
Browse files Browse the repository at this point in the history
Use PHP attribute for ViewsField plugin
  • Loading branch information
Chi-teck committed May 24, 2024
2 parents a4b5581 + 0f24bc0 commit b81e31c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions templates/Plugin/Views/_field/field.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand All @@ -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().
Expand All @@ -37,6 +36,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* }
* @endcode
*/
#[ViewsField('{{ plugin_id }}')]
final class {{ class }} extends FieldPluginBase {

{% if services %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand All @@ -27,6 +26,7 @@
* }
* @endcode
*/
#[ViewsField('foo_example')]
final class Example extends FieldPluginBase {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
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;

/**
* 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().
Expand All @@ -30,6 +29,7 @@
* }
* @endcode
*/
#[ViewsField('foo_example')]
final class Example extends FieldPluginBase {

/**
Expand Down

0 comments on commit b81e31c

Please sign in to comment.