Will replace placeholders in the #text offsets.
array $data: Data structures where to replace placeholders.
$variables: Key value pairs.
protected function replacePlaceholders(&$data, $variables) {
foreach (Element::children($data) as $key) {
if (isset($data[$key]['#text'])) {
$data[$key]['#text'] = (string) new FormattableMarkup($data[$key]['#text'], $variables);
}
else {
$this
->replacePlaceholders($data[$key], $variables);
}
}
}