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\HandlerBase::init().

Overrides FieldPluginBase::init

File

lib/Views/taxonomy/Plugin/views/field/TaxonomyIndexTid.php, line 26
Definition of Views\taxonomy\Plugin\views\field\TaxonomyIndexTid.

Class

TaxonomyIndexTid
Field handler to display all taxonomy terms of a node.

Namespace

Views\taxonomy\Plugin\views\field

Code

public function init(ViewExecutable $view, &$options) {
  parent::init($view, $options);

  // @todo: Wouldn't it be possible to use $this->base_table and no if here?
  if ($view->storage->base_table == 'node_revision') {
    $this->additional_fields['nid'] = array(
      'table' => 'node_revision',
      'field' => 'nid',
    );
  }
  else {
    $this->additional_fields['nid'] = array(
      'table' => 'node',
      'field' => 'nid',
    );
  }

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