protected function Roles::addSelfTokens in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/user/src/Plugin/views/field/Roles.php \Drupal\user\Plugin\views\field\Roles::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/ user/ src/ Plugin/ views/ field/ Roles.php, line 107 - Contains \Drupal\user\Plugin\views\field\Roles.
Class
- Roles
- Field handler to provide a list of roles.
Namespace
Drupal\user\Plugin\views\fieldCode
protected function addSelfTokens(&$tokens, $item) {
if (!empty($item['role'])) {
$tokens['{{ ' . $this->options['id'] . '__role' . ' }}'] = $item['role'];
$tokens['{{ ' . $this->options['id'] . '__rid' . ' }}'] = $item['rid'];
}
}