function PluginBase::getAvailableGlobalTokens
Same name in other branches
- 8.9.x core/modules/views/src/Plugin/views/PluginBase.php \Drupal\views\Plugin\views\PluginBase::getAvailableGlobalTokens()
- 10 core/modules/views/src/Plugin/views/PluginBase.php \Drupal\views\Plugin\views\PluginBase::getAvailableGlobalTokens()
- 11.x core/modules/views/src/Plugin/views/PluginBase.php \Drupal\views\Plugin\views\PluginBase::getAvailableGlobalTokens()
Overrides ViewsPluginInterface::getAvailableGlobalTokens
1 call to PluginBase::getAvailableGlobalTokens()
- PluginBase::globalTokenForm in core/
modules/ views/ src/ Plugin/ views/ PluginBase.php - Adds elements for available core tokens to a form.
File
-
core/
modules/ views/ src/ Plugin/ views/ PluginBase.php, line 432
Class
- PluginBase
- Base class for any views plugin types.
Namespace
Drupal\views\Plugin\viewsCode
public function getAvailableGlobalTokens($prepared = FALSE, array $types = []) {
$info = \Drupal::token()->getInfo();
// Site and view tokens should always be available.
$types += [
'site',
'view',
];
$available = array_intersect_key($info['tokens'], array_flip($types));
// Construct the token string for each token.
if ($prepared) {
$prepared = [];
foreach ($available as $type => $tokens) {
foreach (array_keys($tokens) as $token) {
$prepared[$type][] = "[{$type}:{$token}]";
}
}
return $prepared;
}
return $available;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.