function TaxonomyTokensHooks::tokenInfo
Implements hook_token_info().
File
-
core/
modules/ taxonomy/ src/ Hook/ TaxonomyTokensHooks.php, line 19
Class
- TaxonomyTokensHooks
- Hook implementations for taxonomy.
Namespace
Drupal\taxonomy\HookCode
public function tokenInfo() {
$types['term'] = [
'name' => t("Taxonomy terms"),
'description' => t("Tokens related to taxonomy terms."),
'needs-data' => 'term',
];
$types['vocabulary'] = [
'name' => t("Vocabularies"),
'description' => t("Tokens related to taxonomy vocabularies."),
'needs-data' => 'vocabulary',
];
// Taxonomy term related variables.
$term['tid'] = [
'name' => t("Term ID"),
'description' => t("The unique ID of the taxonomy term."),
];
$term['uuid'] = [
'name' => t('UUID'),
'description' => t("The UUID of the taxonomy term."),
];
$term['name'] = [
'name' => t("Name"),
'description' => t("The name of the taxonomy term."),
];
$term['description'] = [
'name' => t("Description"),
'description' => t("The optional description of the taxonomy term."),
];
$term['node-count'] = [
'name' => t("Node count"),
'description' => t("The number of nodes tagged with the taxonomy term."),
];
$term['url'] = [
'name' => t("URL"),
'description' => t("The URL of the taxonomy term."),
];
// Taxonomy vocabulary related variables.
$vocabulary['vid'] = [
'name' => t("Vocabulary ID"),
'description' => t("The unique ID of the taxonomy vocabulary."),
];
$vocabulary['name'] = [
'name' => t("Name"),
'description' => t("The name of the taxonomy vocabulary."),
];
$vocabulary['description'] = [
'name' => t("Description"),
'description' => t("The optional description of the taxonomy vocabulary."),
];
$vocabulary['node-count'] = [
'name' => t("Node count"),
'description' => t("The number of nodes tagged with terms belonging to the taxonomy vocabulary."),
];
$vocabulary['term-count'] = [
'name' => t("Term count"),
'description' => t("The number of terms belonging to the taxonomy vocabulary."),
];
// Chained tokens for taxonomies
$term['vocabulary'] = [
'name' => t("Vocabulary"),
'description' => t("The vocabulary the taxonomy term belongs to."),
'type' => 'vocabulary',
];
$term['parent'] = [
'name' => t("Parent term"),
'description' => t("The parent term of the taxonomy term, if one exists."),
'type' => 'term',
];
$term['changed'] = [
'name' => t("Date changed"),
'description' => t("The date the taxonomy was most recently updated."),
'type' => 'date',
];
return [
'types' => $types,
'tokens' => [
'term' => $term,
'vocabulary' => $vocabulary,
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.