VocabularyVid.php in Drupal 10
File
core/modules/taxonomy/src/Plugin/views/argument/VocabularyVid.php
View source
<?php
namespace Drupal\taxonomy\Plugin\views\argument;
use Drupal\views\Plugin\views\argument\NumericArgument;
use Drupal\taxonomy\VocabularyStorageInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class VocabularyVid extends NumericArgument {
protected $vocabularyStorage;
public function __construct(array $configuration, $plugin_id, $plugin_definition, VocabularyStorageInterface $vocabulary_storage) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->vocabularyStorage = $vocabulary_storage;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('entity_type.manager')
->getStorage('taxonomy_vocabulary'));
}
public function title() {
$vocabulary = $this->vocabularyStorage
->load($this->argument);
if ($vocabulary) {
return $vocabulary
->label();
}
return $this
->t('No vocabulary');
}
}