// Optionally alter the list of replacement values.
if (!
empty($options['callback'
])) { $function =
$options['callback'
];
$function($replacements,
$data,
$options,
$bubbleable_metadata);
} $tokens =
array_keys($replacements);
$values =
array_values($replacements);
// If a local $bubbleable_metadata object was created, apply the metadata
// it collected to the renderer's currently active render context.
if (!
$bubbleable_metadata_is_passed_in &&
$this->renderer->
hasRenderContext()) { $build =
[];
$bubbleable_metadata->
applyTo($build);
$this->renderer->
render($build);
} return str_replace($tokens,
$values,
$text);
} /**
* Builds a list of all token-like patterns that appear in the text.
*
* @param string $text
* The text to be scanned for possible tokens.
*
* @return array
* An associative array of discovered tokens, grouped by type.
*/