Verified Commit 69947589 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3421003 by sorlov, quietone, pradhumanjain2311, smustgrave, larowlan,...

Issue #3421003 by sorlov, quietone, pradhumanjain2311, smustgrave, larowlan, alexpott: Convert ViewsArgumentDefault plugin discovery to attributes
parent 8f28c48d
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -3,18 +3,19 @@
namespace Drupal\book\Plugin\views\argument_default;

use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\node\NodeStorageInterface;
use Drupal\node\Plugin\views\argument_default\Node;
use Drupal\views\Attribute\ViewsArgumentDefault;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Default argument plugin to get the current node's top level book.
 *
 * @ViewsArgumentDefault(
 *   id = "top_level_book",
 *   title = @Translation("Top Level Book from current node")
 * )
 */
#[ViewsArgumentDefault(
  id: 'top_level_book',
  title: new TranslatableMarkup('Top Level Book from current node"'),
)]
class TopLevelBook extends Node {

  /**
+6 −5
Original line number Diff line number Diff line
@@ -5,18 +5,19 @@
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\views\Attribute\ViewsArgumentDefault;
use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase;
use Drupal\node\NodeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Default argument plugin to extract a node.
 *
 * @ViewsArgumentDefault(
 *   id = "node",
 *   title = @Translation("Content ID from URL")
 * )
 */
#[ViewsArgumentDefault(
  id: 'node',
  title: new TranslatableMarkup('Content ID from URL'),
)]
class Node extends ArgumentDefaultPluginBase implements CacheableDependencyInterface {

  /**
+6 −5
Original line number Diff line number Diff line
@@ -6,7 +6,9 @@
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\taxonomy\TermInterface;
use Drupal\views\Attribute\ViewsArgumentDefault;
use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase;
use Drupal\node\NodeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -14,12 +16,11 @@

/**
 * Taxonomy tid default argument.
 *
 * @ViewsArgumentDefault(
 *   id = "taxonomy_tid",
 *   title = @Translation("Taxonomy term ID from URL")
 * )
 */
#[ViewsArgumentDefault(
  id: 'taxonomy_tid',
  title: new TranslatableMarkup('Taxonomy term ID from URL'),
)]
class Tid extends ArgumentDefaultPluginBase implements CacheableDependencyInterface {

  /**
+6 −5
Original line number Diff line number Diff line
@@ -4,18 +4,19 @@

use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\views\Attribute\ViewsArgumentDefault;
use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase;

/**
 * Default argument plugin to extract the current user.
 *
 * This plugin actually has no options so it does not need to do a great deal.
 *
 * @ViewsArgumentDefault(
 *   id = "current_user",
 *   title = @Translation("User ID from logged in user")
 * )
 */
#[ViewsArgumentDefault(
  id: 'current_user',
  title: new TranslatableMarkup('User ID from logged in user'),
)]
class CurrentUser extends ArgumentDefaultPluginBase implements CacheableDependencyInterface {

  /**
+6 −5
Original line number Diff line number Diff line
@@ -6,6 +6,8 @@
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;
use Drupal\user\UserInterface;
@@ -13,12 +15,11 @@

/**
 * Default argument plugin to extract a user from request.
 *
 * @ViewsArgumentDefault(
 *   id = "user",
 *   title = @Translation("User ID from route context")
 * )
 */
#[ViewsArgumentDefault(
  id: 'user',
  title: new TranslatableMarkup('User ID from route context"'),
)]
class User extends ArgumentDefaultPluginBase implements CacheableDependencyInterface {

  /**
Loading