public function AliasCleaner::cleanTokenValues in Pathauto 8
Clean tokens so they are URL friendly.
Parameters
array $replacements: An array of token replacements that need to be "cleaned" for use in the URL.
array $data: An array of objects used to generate the replacements.
array $options: An array of options used to generate the replacements.
Overrides AliasCleanerInterface::cleanTokenValues
File
- src/
AliasCleaner.php, line 342
Class
- AliasCleaner
- Provides an alias cleaner.
Namespace
Drupal\pathautoCode
public function cleanTokenValues(&$replacements, $data = [], $options = []) {
foreach ($replacements as $token => $value) {
// Only clean non-path tokens.
$config = $this->configFactory
->get('pathauto.settings');
$safe_tokens = implode('|', (array) $config
->get('safe_tokens'));
if (!preg_match('/(\\[|\\:)(' . $safe_tokens . ')(:|\\]$)/', $token)) {
$replacements[$token] = $this
->cleanString($value, $options);
}
}
}