5 * Token integration for the Pathauto module.
8 use Drupal\Core\Render\BubbleableMetadata;
11 * Implements hook_token_info().
13 function pathauto_token_info() {
16 $info['tokens']['array']['join-path'] = array(
17 'name' => t('Joined path'),
18 'description' => t('The array values each cleaned by Pathauto and then joined with the slash into a string that resembles an URL.'),
25 * Implements hook_tokens().
27 function pathauto_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
28 $replacements = array();
30 if ($type == 'array' && !empty($data['array'])) {
31 $array = $data['array'];
33 foreach ($tokens as $name => $original) {
37 foreach (token_element_children($array) as $key) {
38 $value = is_array($array[$key]) ? render($array[$key]) : (string) $array[$key];
39 $value = \Drupal::service('pathauto.alias_cleaner')->cleanString($value, $options);
42 $replacements[$original] = implode('/', $values);