Pathologic was missing because of a .git folder inside.
[yaffs-website] / web / modules / contrib / pathauto / pathauto.tokens.inc
1 <?php
2
3 /**
4  * @file
5  * Token integration for the Pathauto module.
6  */
7
8 use Drupal\Core\Render\BubbleableMetadata;
9
10 /**
11  * Implements hook_token_info().
12  */
13 function pathauto_token_info() {
14   $info = array();
15
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.'),
19   );
20
21   return $info;
22 }
23
24 /**
25  * Implements hook_tokens().
26  */
27 function pathauto_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
28   $replacements = array();
29
30   if ($type == 'array' && !empty($data['array'])) {
31     $array = $data['array'];
32
33     foreach ($tokens as $name => $original) {
34       switch ($name) {
35         case 'join-path':
36           $values = array();
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);
40             $values[] = $value;
41           }
42           $replacements[$original] = implode('/', $values);
43           break;
44       }
45     }
46   }
47
48   return $replacements;
49 }