You are here

public function TaxonomyIndexTid::init in Views (for Drupal 7) 8.3

Same name in this branch
  1. 8.3 lib/Views/taxonomy/Plugin/views/filter/TaxonomyIndexTid.php \Views\taxonomy\Plugin\views\filter\TaxonomyIndexTid::init()
  2. 8.3 lib/Views/taxonomy/Plugin/views/field/TaxonomyIndexTid.php \Views\taxonomy\Plugin\views\field\TaxonomyIndexTid::init()

Overrides Drupal\views\Plugin\views\filter\FilterPluginBase::init().

Overrides ManyToOne::init

File

lib/Views/taxonomy/Plugin/views/filter/TaxonomyIndexTid.php, line 29
Definition of views_handler_filter_term_node_tid.

Class

TaxonomyIndexTid
Filter by term id.

Namespace

Views\taxonomy\Plugin\views\filter

Code

public function init(ViewExecutable $view, &$options) {
  parent::init($view, $options);
  if (!empty($this->definition['vocabulary'])) {
    $this->options['vocabulary'] = $this->definition['vocabulary'];
  }

  // Convert legacy vid option to machine name vocabulary.
  if (isset($this->options['vid']) && !empty($this->options['vid']) & empty($this->options['vocabulary'])) {
    $vocabularies = taxonomy_vocabulary_get_names();
    $vid = $this->options['vid'];
    if (isset($vocabularies[$vid], $vocabularies[$vid]->machine_name)) {
      $this->options['vocabulary'] = $vocabularies[$vid]->machine_name;
    }
  }
}