public function WebformTokenManagerInterface::replace in Webform 6.x
Same name and namespace in other branches
- 8.5 src/WebformTokenManagerInterface.php \Drupal\webform\WebformTokenManagerInterface::replace()
Replace tokens in text.
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.
\Drupal\Core\Render\BubbleableMetadata|null $bubbleable_metadata: (optional) An object to which static::generate() and the hooks and functions that it invokes will add their required bubbleable metadata.
Return value
string|array Text or array with tokens replaced.
See also
\Drupal\Core\Utility\Token::replace
1 method overrides WebformTokenManagerInterface::replace()
- WebformTokenManager::replace in src/
WebformTokenManager.php - Replace tokens in text.
File
- src/
WebformTokenManagerInterface.php, line 40
Class
- WebformTokenManagerInterface
- Defines an interface for token manager classes.
Namespace
Drupal\webformCode
public function replace($text, EntityInterface $entity = NULL, array $data = [], array $options = [], BubbleableMetadata $bubbleable_metadata = NULL);