You are here

public function PlaceholderResolverInterface::resolvePlaceholders in Typed Data API enhancements 8

Replaces all placeholder tokens in a given string with appropriate values.

Parameters

string $text: An HTML string containing replaceable tokens. The caller is responsible for calling \Drupal\Component\Utility\Html::escape() in case the $text was plain text.

\Drupal\Core\TypedData\TypedDataInterface[] $data: The data to use for generating values for the placeholder, keyed by name.

\Drupal\Core\Render\BubbleableMetadata|null $bubbleable_metadata: (optional) An object to which required bubbleable metadata will be added. Refer to ::replacePlaceHolders() for further details.

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.
  • clear: A boolean flag indicating that tokens should be removed from the final text if no replacement value can be generated. Defaults to FALSE.

Return value

\Drupal\Component\Render\MarkupInterface[] An array of replacement values for the placeholders contained in the text, keyed by placeholder.

1 method overrides PlaceholderResolverInterface::resolvePlaceholders()
PlaceholderResolver::resolvePlaceholders in src/PlaceholderResolver.php
Replaces all placeholder tokens in a given string with appropriate values.

File

src/PlaceholderResolverInterface.php, line 48

Class

PlaceholderResolverInterface
Interface for a placeholder resolver based upon typed data.

Namespace

Drupal\typed_data

Code

public function resolvePlaceholders($text, array $data = [], BubbleableMetadata $bubbleable_metadata = NULL, array $options = []);