You are here

class Node in Drupal 10

Same name in this branch
  1. 10 core/modules/node/src/Entity/Node.php \Drupal\node\Entity\Node
  2. 10 core/modules/node/src/Plugin/views/argument_default/Node.php \Drupal\node\Plugin\views\argument_default\Node
  3. 10 core/modules/node/src/Plugin/views/wizard/Node.php \Drupal\node\Plugin\views\wizard\Node
  4. 10 core/modules/node/src/Plugin/views/field/Node.php \Drupal\node\Plugin\views\field\Node
  5. 10 core/modules/node/src/Plugin/migrate/source/d6/Node.php \Drupal\node\Plugin\migrate\source\d6\Node
  6. 10 core/modules/node/src/Plugin/migrate/source/d7/Node.php \Drupal\node\Plugin\migrate\source\d7\Node
Same name and namespace in other branches
  1. 8 core/modules/node/src/Plugin/views/argument_default/Node.php \Drupal\node\Plugin\views\argument_default\Node
  2. 9 core/modules/node/src/Plugin/views/argument_default/Node.php \Drupal\node\Plugin\views\argument_default\Node

Default argument plugin to extract a node.

Plugin annotation


@ViewsArgumentDefault(
  id = "node",
  title = @Translation("Content ID from URL")
)

Hierarchy

  • class \Drupal\node\Plugin\views\argument_default\Node extends \Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase implements CacheableDependencyInterface

Expanded class hierarchy of Node

1 file declares its use of Node
TopLevelBook.php in core/modules/book/src/Plugin/views/argument_default/TopLevelBook.php
24 string references to 'Node'
CategorizingPluginManagerTraitTest::setUp in core/tests/Drupal/Tests/Core/Plugin/CategorizingPluginManagerTraitTest.php
CategorizingPluginManagerTraitTest::testProcessDefinitionCategory in core/tests/Drupal/Tests/Core/Plugin/CategorizingPluginManagerTraitTest.php
@covers ::processDefinitionCategory
CategoryAutocompleteTest::providerTestAutocompleteSuggestions in core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php
Data provider for testAutocompleteSuggestions().
CategoryAutocompleteTest::setUp in core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php
CommentBundlesTest::setUp in core/modules/comment/tests/src/Kernel/CommentBundlesTest.php

... See full list

File

core/modules/node/src/Plugin/views/argument_default/Node.php, line 20

Namespace

Drupal\node\Plugin\views\argument_default
View source
class Node extends ArgumentDefaultPluginBase implements CacheableDependencyInterface {

  /**
   * The route match.
   *
   * @var \Drupal\Core\Routing\RouteMatchInterface
   */
  protected $routeMatch;

  /**
   * Constructs a new Node instance.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
   *   The route match.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, RouteMatchInterface $route_match) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->routeMatch = $route_match;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('current_route_match'));
  }

  /**
   * {@inheritdoc}
   */
  public function getArgument() {
    if (($node = $this->routeMatch
      ->getParameter('node')) && $node instanceof NodeInterface) {
      return $node
        ->id();
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheMaxAge() {
    return Cache::PERMANENT;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheContexts() {
    return [
      'url',
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableDependencyInterface::getCacheTags public function The cache tags associated with this object. 14
Node::$routeMatch protected property The route match.
Node::create public static function 1
Node::getArgument public function 1
Node::getCacheContexts public function The cache contexts associated with this object. Overrides CacheableDependencyInterface::getCacheContexts
Node::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides CacheableDependencyInterface::getCacheMaxAge
Node::__construct public function Constructs a new Node instance. 1