You are here

protected function FieldTest::addSelfTokens in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldTest.php \Drupal\views_test_data\Plugin\views\field\FieldTest::addSelfTokens()
  2. 10 core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldTest.php \Drupal\views_test_data\Plugin\views\field\FieldTest::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/views/tests/modules/views_test_data/src/Plugin/views/field/FieldTest.php, line 43

Class

FieldTest
Plugin annotation @ViewsField("test_field");

Namespace

Drupal\views_test_data\Plugin\views\field

Code

protected function addSelfTokens(&$tokens, $item) {
  $tokens['{{ test_token }}'] = $this
    ->getTestValue();
}