3 namespace Drupal\taxonomy\Plugin\views\argument;
5 use Drupal\views\Plugin\views\argument\NumericArgument;
6 use Drupal\taxonomy\VocabularyStorageInterface;
7 use Symfony\Component\DependencyInjection\ContainerInterface;
10 * Argument handler to accept a vocabulary id.
12 * @ingroup views_argument_handlers
14 * @ViewsArgument("vocabulary_vid")
16 class VocabularyVid extends NumericArgument {
19 * The vocabulary storage.
21 * @var \Drupal\taxonomy\VocabularyStorageInterface
23 protected $vocabularyStorage;
26 * Constructs the VocabularyVid object.
28 * @param array $configuration
29 * A configuration array containing information about the plugin instance.
30 * @param string $plugin_id
31 * The plugin_id for the plugin instance.
32 * @param mixed $plugin_definition
33 * The plugin implementation definition.
34 * @param \Drupal\taxonomy\VocabularyStorageInterface $vocabulary_storage
35 * The vocabulary storage.
37 public function __construct(array $configuration, $plugin_id, $plugin_definition, VocabularyStorageInterface $vocabulary_storage) {
38 parent::__construct($configuration, $plugin_id, $plugin_definition);
39 $this->vocabularyStorage = $vocabulary_storage;
45 public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
50 $container->get('entity.manager')->getStorage('taxonomy_vocabulary')
55 * Override the behavior of title(). Get the name of the vocabulary.
57 public function title() {
58 $vocabulary = $this->vocabularyStorage->load($this->argument);
60 return $vocabulary->label();
63 return $this->t('No vocabulary');