Type.php

Definition of Drupal\node\Plugin\views\argument\Type.

Namespace

Drupal\node\Plugin\views\argument

File

drupal/core/modules/node/lib/Drupal/node/Plugin/views/argument/Type.php
View source
<?php

/**
 * @file
 * Definition of Drupal\node\Plugin\views\argument\Type.
 */
namespace Drupal\node\Plugin\views\argument;

use Drupal\views\Plugin\views\argument\String;
use Drupal\Core\Annotation\Plugin;

/**
 * Argument handler to accept a node type.
 *
 * @Plugin(
 *   id = "node_type",
 *   module = "node"
 * )
 */
class Type extends String {

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

  /**
   * Override the behavior of title(). Get the user friendly version of the
   * node type.
   */
  function title() {
    return $this
      ->node_type($this->argument);
  }
  function node_type($type) {
    $output = node_type_get_label($type);
    if (empty($output)) {
      $output = t('Unknown content type');
    }
    return check_plain($output);
  }

}

Classes

Namesort descending Description
Type Argument handler to accept a node type.