public function PluginBase::globalTokenForm in Drupal 10
Same name and namespace in other branches
- 8 core/modules/views/src/Plugin/views/PluginBase.php \Drupal\views\Plugin\views\PluginBase::globalTokenForm()
- 9 core/modules/views/src/Plugin/views/PluginBase.php \Drupal\views\Plugin\views\PluginBase::globalTokenForm()
File
- core/
modules/ views/ src/ Plugin/ views/ PluginBase.php, line 452
Class
Namespace
Drupal\views\Plugin\viewsCode
public function globalTokenForm(&$form, FormStateInterface $form_state) {
$token_items = [];
foreach ($this
->getAvailableGlobalTokens() as $type => $tokens) {
$item = [
'#markup' => $type,
'children' => [],
];
foreach ($tokens as $name => $info) {
$item['children'][$name] = "[{$type}:{$name}]" . ' - ' . $info['name'] . ': ' . $info['description'];
}
$token_items[$type] = $item;
}
$form['global_tokens'] = [
'#type' => 'details',
'#title' => $this
->t('Available global token replacements'),
];
$form['global_tokens']['list'] = [
'#theme' => 'item_list',
'#items' => $token_items,
'#attributes' => [
'class' => [
'global-tokens',
],
],
];
}