protected function WebformTokenManager::prepareSuffixes in Webform 6.x
Same name and namespace in other branches
- 8.5 src/WebformTokenManager.php \Drupal\webform\WebformTokenManager::prepareSuffixes()
Prepare token suffixes to be replaced and processed.
Prepare token suffixes by wrapping them in temp {webform-token-suffixes} tags.
[webform:token:clear:urlencode] becomes {webform-token-suffixes:clear:urlencode}[webform:token]{/webform-token-suffixes}.
Parameters
string|array $text: A string of text that may contain tokens.
array $suffixes: An array of supported suffixes.
Return value
string A string of text with token suffixes wrapped in {webform-token-suffixes} tags.
1 call to WebformTokenManager::prepareSuffixes()
- WebformTokenManager::replace in src/
WebformTokenManager.php - Replace tokens in text.
File
- src/
WebformTokenManager.php, line 406
Class
- WebformTokenManager
- Defines a class to manage token replacement.
Namespace
Drupal\webformCode
protected function prepareSuffixes($text, array $suffixes) {
if (preg_match_all('/\\[([^\\]]+?)((?::' . implode('|:', $suffixes) . ')+)\\]/', $text, $matches)) {
foreach ($matches[0] as $index => $match) {
$value = $matches[1][$index];
$suffixes = $matches[2][$index];
$wrapper = '{webform-token-suffixes' . $suffixes . '}[' . $value . ']{/webform-token-suffixes}';
$text = str_replace($match, $wrapper, $text);
}
}
return $text;
}