You are here

class Type in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/node/src/Plugin/views/argument/Type.php \Drupal\node\Plugin\views\argument\Type
  2. 9 core/modules/node/src/Plugin/views/argument/Type.php \Drupal\node\Plugin\views\argument\Type

Argument handler to accept a node type.

Plugin annotation

@ViewsArgument("node_type");

Hierarchy

  • class \Drupal\node\Plugin\views\argument\Type extends \Drupal\views\Plugin\views\argument\StringArgument

Expanded class hierarchy of Type

35 string references to 'Type'
DbDumpCommand::getTableSchema in core/lib/Drupal/Core/Command/DbDumpCommand.php
Returns a schema array for a given table.
DbDumpTest::getTableSchema in core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php
Helper function to get a simplified schema for a given table.
DbLogController::eventDetails in core/modules/dblog/src/Controller/DbLogController.php
Displays details about a specific database log message.
DbLogController::overview in core/modules/dblog/src/Controller/DbLogController.php
Displays a listing of database log messages.
DbLogTest::testDbLog in core/modules/dblog/tests/src/Functional/DbLogTest.php
Tests Database Logging module functionality through interfaces.

... See full list

File

core/modules/node/src/Plugin/views/argument/Type.php, line 14

Namespace

Drupal\node\Plugin\views\argument
View source
class Type extends StringArgument {

  /**
   * NodeType storage handler.
   *
   * @var \Drupal\Core\Entity\EntityStorageInterface
   */
  protected $nodeTypeStorage;

  /**
   * Constructs a new Node Type object.
   *
   * @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\Entity\EntityStorageInterface $node_type_storage
   *   The entity storage class.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityStorageInterface $node_type_storage) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->nodeTypeStorage = $node_type_storage;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    $entity_type_manager = $container
      ->get('entity_type.manager');
    return new static($configuration, $plugin_id, $plugin_definition, $entity_type_manager
      ->getStorage('node_type'));
  }

  /**
   * Override the behavior of summaryName(). Get the user friendly version
   * of the node type.
   */
  public function summaryName($data) {
    return $this
      ->node_type($data->{$this->name_alias});
  }

  /**
   * Override the behavior of title(). Get the user friendly version of the
   * node type.
   */
  public function title() {
    return $this
      ->node_type($this->argument);
  }
  public function node_type($type_name) {
    $type = $this->nodeTypeStorage
      ->load($type_name);
    $output = $type ? $type
      ->label() : $this
      ->t('Unknown content type');
    return $output;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Type::$nodeTypeStorage protected property NodeType storage handler.
Type::create public static function
Type::node_type public function
Type::summaryName public function Override the behavior of summaryName(). Get the user friendly version of the node type.
Type::title public function Override the behavior of title(). Get the user friendly version of the node type.
Type::__construct public function Constructs a new Node Type object.