public function WebformTokenManager::replaceNoRenderContext in Webform 6.x
Same name and namespace in other branches
- 8.5 src/WebformTokenManager.php \Drupal\webform\WebformTokenManager::replaceNoRenderContext()
Replace tokens in text with no render context.
This method allows tokens to be replaced when there is no render context via REST and JSON API requests.
Parameters
string|array $text: A string of text that may contain tokens.
\Drupal\Core\Entity\EntityInterface|null $entity: A Webform or Webform submission entity.
array $data: (optional) An array of keyed objects.
array $options: (optional) A keyed array of settings and flags to control the token replacement process. Supported options are:
- langcode: A language code to be used when generating locale-sensitive tokens.
- callback: A callback function that will be used to post-process the array of token replacements after they are generated.
- clear: A boolean flag indicating that tokens should be removed from the final text if no replacement value can be generated.
Return value
string|array Text or array with tokens replaced.
Overrides WebformTokenManagerInterface::replaceNoRenderContext
See also
\Drupal\Core\Utility\Token::replace
File
- src/
WebformTokenManager.php, line 167
Class
- WebformTokenManager
- Defines a class to manage token replacement.
Namespace
Drupal\webformCode
public function replaceNoRenderContext($text, EntityInterface $entity = NULL, array $data = [], array $options = []) {
// Create BubbleableMetadata object which will be ignored.
$bubbleable_metadata = new BubbleableMetadata();
return $this
->replace($text, $entity, $data, $options, $bubbleable_metadata);
}