function token_render_array in Token 8
Same name and namespace in other branches
- 7 token.module \token_render_array()
Do not use this function yet. Its API has not been finalized.
2 calls to token_render_array()
- book_tokens in ./
token.tokens.inc - Implements hook_tokens() on behalf of book.module.
- token_tokens in ./
token.tokens.inc - Implements hook_tokens().
File
- ./
token.module, line 446 - Enhances the token API in core: adds a browseable UI, missing tokens, etc.
Code
function token_render_array(array $array, array $options = []) {
$rendered = [];
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
foreach (token_element_children($array) as $key) {
$value = $array[$key];
$rendered[] = is_array($value) ? $renderer
->renderPlain($value) : (string) $value;
}
$join = isset($options['join']) ? $options['join'] : ', ';
return implode($join, $rendered);
}