You are here

function taxonomy_machine_name_tokens in Taxonomy Machine Name 8

Implements hook_tokens().

File

./taxonomy_machine_name.module, line 288
This is the Taxonomy Machine Name module.

Code

function taxonomy_machine_name_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
  $replacements = [];
  if ($type == 'term' && !empty($data['term'])) {
    $term = $data['term'];
    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'machine_name':
          $replacements[$original] = $term->machine_name->value;
          break;
      }
    }
  }
  return $replacements;
}