function TaxonomyTokensHooks::tokenInfo

Implements hook_token_info().

Attributes

#[Hook('token_info')]

File

core/modules/taxonomy/src/Hook/TaxonomyTokensHooks.php, line 22

Class

TaxonomyTokensHooks
Hook implementations for taxonomy.

Namespace

Drupal\taxonomy\Hook

Code

public function tokenInfo() : array {
  $types['term'] = [
    'name' => $this->t("Taxonomy terms"),
    'description' => $this->t("Tokens related to taxonomy terms."),
    'needs-data' => 'term',
  ];
  $types['vocabulary'] = [
    'name' => $this->t("Vocabularies"),
    'description' => $this->t("Tokens related to taxonomy vocabularies."),
    'needs-data' => 'vocabulary',
  ];
  // Taxonomy term related variables.
  $term['tid'] = [
    'name' => $this->t("Term ID"),
    'description' => $this->t("The unique ID of the taxonomy term."),
  ];
  $term['uuid'] = [
    'name' => $this->t('UUID'),
    'description' => $this->t("The UUID of the taxonomy term."),
  ];
  $term['name'] = [
    'name' => $this->t("Name"),
    'description' => $this->t("The name of the taxonomy term."),
  ];
  $term['description'] = [
    'name' => $this->t("Description"),
    'description' => $this->t("The optional description of the taxonomy term."),
  ];
  $term['node-count'] = [
    'name' => $this->t("Node count"),
    'description' => $this->t("The number of nodes tagged with the taxonomy term."),
  ];
  $term['url'] = [
    'name' => $this->t("URL"),
    'description' => $this->t("The URL of the taxonomy term."),
  ];
  // Taxonomy vocabulary related variables.
  $vocabulary['vid'] = [
    'name' => $this->t("Vocabulary ID"),
    'description' => $this->t("The unique ID of the taxonomy vocabulary."),
  ];
  $vocabulary['name'] = [
    'name' => $this->t("Name"),
    'description' => $this->t("The name of the taxonomy vocabulary."),
  ];
  $vocabulary['description'] = [
    'name' => $this->t("Description"),
    'description' => $this->t("The optional description of the taxonomy vocabulary."),
  ];
  $vocabulary['node-count'] = [
    'name' => $this->t("Node count"),
    'description' => $this->t("The number of nodes tagged with terms belonging to the taxonomy vocabulary."),
  ];
  $vocabulary['term-count'] = [
    'name' => $this->t("Term count"),
    'description' => $this->t("The number of terms belonging to the taxonomy vocabulary."),
  ];
  // Chained tokens for taxonomies
  $term['vocabulary'] = [
    'name' => $this->t("Vocabulary"),
    'description' => $this->t("The vocabulary the taxonomy term belongs to."),
    'type' => 'vocabulary',
  ];
  $term['parent'] = [
    'name' => $this->t("Parent term"),
    'description' => $this->t("The parent term of the taxonomy term, if one exists."),
    'type' => 'term',
  ];
  $term['changed'] = [
    'name' => $this->t("Date changed"),
    'description' => $this->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.