Skip to content
Snippets Groups Projects
Commit 3e2a84c7 authored by Martin Anderson-Clutz's avatar Martin Anderson-Clutz
Browse files

Issue #3200679 by bgilhome: Error: Render context is empty

parent ce41bc23
No related branches found
No related tags found
No related merge requests found
......@@ -70,6 +70,7 @@ function token_entity_render_tokens($type, array $tokens, array $data, array $op
$all_view_modes = \Drupal::service('entity.manager')->getStorage('entity_view_mode')->loadMultiple();
// Traverse again all tokens to process.
$renderer = \Drupal::service('renderer');
foreach ($to_process as $token_replaceable_value => $view_mode_name) {
// If the view mode actually exists and if the entity type matches.
if (($view_mode = $all_view_modes[$data['entity_type'] . '.' . $view_mode_name])) {
......@@ -79,7 +80,7 @@ function token_entity_render_tokens($type, array $tokens, array $data, array $op
$rendered_entity = \Drupal::entityTypeManager()->getViewBuilder($view_mode->getTargetType())->view($data['entity'], $mode_machine_name);
// Add the replacement.
$replacements[$token_replaceable_value] = render($rendered_entity);
$replacements[$token_replaceable_value] = $renderer->renderPlain($rendered_entity);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment