You are here

class VocabularyVid in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/taxonomy/src/Plugin/views/argument/VocabularyVid.php \Drupal\taxonomy\Plugin\views\argument\VocabularyVid
  2. 9 core/modules/taxonomy/src/Plugin/views/argument/VocabularyVid.php \Drupal\taxonomy\Plugin\views\argument\VocabularyVid

Argument handler to accept a vocabulary id.

Plugin annotation

@ViewsArgument("vocabulary_vid");

Hierarchy

  • class \Drupal\views\Plugin\views\argument\NumericArgument extends \Drupal\views\Plugin\views\argument\ArgumentPluginBase

Expanded class hierarchy of VocabularyVid

File

core/modules/taxonomy/src/Plugin/views/argument/VocabularyVid.php, line 16

Namespace

Drupal\taxonomy\Plugin\views\argument
View source
class VocabularyVid extends NumericArgument {

  /**
   * The vocabulary storage.
   *
   * @var \Drupal\taxonomy\VocabularyStorageInterface
   */
  protected $vocabularyStorage;

  /**
   * Constructs the VocabularyVid object.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   * @param \Drupal\taxonomy\VocabularyStorageInterface $vocabulary_storage
   *   The vocabulary storage.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, VocabularyStorageInterface $vocabulary_storage) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->vocabularyStorage = $vocabulary_storage;
  }

  /**
   * {@inheritdoc}
   */
  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'));
  }

  /**
   * Override the behavior of title(). Get the name of the vocabulary.
   */
  public function title() {
    $vocabulary = $this->vocabularyStorage
      ->load($this->argument);
    if ($vocabulary) {
      return $vocabulary
        ->label();
    }
    return $this
      ->t('No vocabulary');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
NumericArgument::$value public property The actual value which is used for querying.
NumericArgument::buildOptionsForm public function 1
NumericArgument::defineOptions protected function 1
NumericArgument::getContextDefinition public function
NumericArgument::getSortName public function
NumericArgument::query public function 1
NumericArgument::titleQuery public function Override for specific title lookups. 4
VocabularyVid::$vocabularyStorage protected property The vocabulary storage.
VocabularyVid::create public static function
VocabularyVid::title public function Override the behavior of title(). Get the name of the vocabulary. Overrides NumericArgument::title
VocabularyVid::__construct public function Constructs the VocabularyVid object.