You are here

public function TokenInterface::replace in Doubleclick for Publishers (DFP) 8

Replaces all tokens in a given string with appropriate values.

Parameters

string $text: An HTML string containing replaceable tokens.

\Drupal\dfp\View\TagView $tag: (optional) An TagView object that merges values of the Tag and global settings. Defaults to NULL.

array $options: (optional) A keyed array of settings and flags to control the token replacement process.

\Drupal\Core\Render\BubbleableMetadata $bubbleable_metadata: (optional) An object to which static::generate() and the hooks and functions that it invokes will add their required bubbleable metadata. Defaults to NULL.

Return value

string The token result is the entered HTML text with tokens replaced. The caller is responsible for choosing the right escaping / sanitization. If the result is intended to be used as plain text, using PlainTextOutput::renderFromHtml() is recommended. If the result is just printed as part of a template relying on Twig autoescaping is possible, otherwise for example the result can be put into #markup, in which case it would be sanitized by Xss::filterAdmin().

See also

\Drupal\Core\Utility\Token::replace()

1 method overrides TokenInterface::replace()
Token::replace in src/Token.php
Replaces all tokens in a given string with appropriate values.

File

src/TokenInterface.php, line 45
Contains \Drupal\dfp\TokenInterface.

Class

TokenInterface
Interface for the DFP token service.

Namespace

Drupal\dfp

Code

public function replace($text, TagView $tag = NULL, array $options = [], BubbleableMetadata $bubbleable_metadata = NULL);