You are here

protected function ViewsSystemRequiredBy::addSelfTokens in Views System 8

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

src/Plugin/views/field/ViewsSystemRequiredBy.php, line 52
Contains \Drupal\views_system\Plugin\views\field\ViewsSystemRequiredBy.

Class

ViewsSystemRequiredBy
Field handler to display all other items that depends on this item.

Namespace

Drupal\views_system\Plugin\views\field

Code

protected function addSelfTokens(&$tokens, $item) {
  if (!empty($item['name'])) {
    $tokens['{{ ' . $this->options['id'] . '__label' . ' }}'] = $item['label'];
    $tokens['{{ ' . $this->options['id'] . '__name' . ' }}'] = $item['name'];
  }
}