Taxonomy.php 769 Bytes
Newer Older
1 2 3 4
<?php

/**
 * @file
5
 * Definition of Drupal\taxonomy\Plugin\views\argument\Taxonomy.
6 7
 */

8
namespace Drupal\taxonomy\Plugin\views\argument;
9 10

use Drupal\views\Plugin\views\argument\Numeric;
11
use Drupal\Component\Utility\String;
12

13 14 15 16
/**
 * Argument handler for basic taxonomy tid.
 *
 * @ingroup views_argument_handlers
17
 *
18
 * @ViewsArgument("taxonomy")
19 20
 */
class Taxonomy extends Numeric {
21 22 23 24 25 26 27

  /**
   * Override the behavior of title(). Get the title of the node.
   */
  function title() {
    // There might be no valid argument.
    if ($this->argument) {
28
      $term = entity_load('taxonomy_term', $this->argument);
29
      if (!empty($term)) {
30
        return String::checkPlain($term->getName());
31 32 33
      }
    }
    // TODO review text
34
    return $this->t('No name');
35
  }
36

37
}