You are here

protected function TaxonomyIndexTid::addSelfTokens in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php \Drupal\taxonomy\Plugin\views\field\TaxonomyIndexTid::addSelfTokens()

Add any special tokens this field might use for itself.

This method is intended to be overridden by items that generate fields as a list. For example, the field that displays all terms on a node might have tokens for the tid and the term.

By convention, tokens should follow the format of {{ token subtoken }} where token is the field ID and subtoken is the field. If the field ID is terms, then the tokens might be {{ terms__tid }} and {{ terms__name }}.

Overrides FieldPluginBase::addSelfTokens

File

core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php, line 176
Contains \Drupal\taxonomy\Plugin\views\field\TaxonomyIndexTid.

Class

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

Namespace

Drupal\taxonomy\Plugin\views\field

Code

protected function addSelfTokens(&$tokens, $item) {
  foreach (array(
    'tid',
    'name',
    'vocabulary_vid',
    'vocabulary',
  ) as $token) {
    $tokens['{{ ' . $this->options['id'] . '__' . $token . ' }}'] = isset($item[$token]) ? $item[$token] : '';
  }
}