function type_style_token_info in Type Style 8
Implements hook_token_info().
File
- ./
type_style.tokens.inc, line 35 - Token hook implementations for the Type Style module.
Code
function type_style_token_info() {
$tokens = [];
foreach (\Drupal::entityTypeManager()
->getDefinitions() as $definition) {
if ($definition instanceof ConfigEntityType && ($type = $definition
->getBundleOf())) {
$label = $definition
->getLabel();
$tokens[$type]['type-style-color'] = [
'name' => t('@label color', [
'@label' => $label,
]),
'description' => t('The color of the related type'),
];
$tokens[$type]['type-style-icon'] = [
'name' => t('@label icon', [
'@label' => $label,
]),
'description' => t('The icon of the related type'),
];
$tokens[$type]['type-style-*'] = [
'name' => t('@label custom style', [
'@label' => $label,
]),
'description' => t('A custom style, i.e. type-style-aura'),
];
}
}
return [
'tokens' => $tokens,
];
}