3 namespace Drupal\taxonomy\Plugin\views\argument;
5 use Drupal\Core\Entity\EntityStorageInterface;
6 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
7 use Drupal\views\Plugin\views\argument\NumericArgument;
8 use Symfony\Component\DependencyInjection\ContainerInterface;
11 * Argument handler for basic taxonomy tid.
13 * @ingroup views_argument_handlers
15 * @ViewsArgument("taxonomy")
17 class Taxonomy extends NumericArgument implements ContainerFactoryPluginInterface {
20 * @var \Drupal\Core\Entity\EntityStorageInterface
22 protected $termStorage;
27 public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityStorageInterface $term_storage) {
28 parent::__construct($configuration, $plugin_id, $plugin_definition);
30 $this->termStorage = $term_storage;
36 public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
41 $container->get('entity.manager')->getStorage('taxonomy_term')
46 * Override the behavior of title(). Get the title of the node.
48 public function title() {
49 // There might be no valid argument.
50 if ($this->argument) {
51 $term = $this->termStorage->load($this->argument);
53 return $term->getName();
57 return $this->t('No name');