Skip to main content
added 275 characters in body
Source Link
Clive
  • 168k
  • 19
  • 303
  • 337

It was replaced with the renderer service:.

$rendered$render_service = \Drupal::service('renderer')->render($renderArray);

The change record is slightlyAs mpdonadio and 4k4 have pointed out of date;in the method iscomments, to prevent metadata from bubbling up to the main request, you should execute this in a new render context. You can do so by using the renderrenderPlain method, rather than the usual renderElementrender these daysmethod (unless you're returning this from a controller, in which case use renderRoot instead).

$rendered = $render_service->renderPlain($build);

It was replaced with the renderer service:

$rendered = \Drupal::service('renderer')->render($renderArray);

The change record is slightly out of date; the method is render rather than renderElement these days.

It was replaced with the renderer service.

$render_service = \Drupal::service('renderer');

As mpdonadio and 4k4 have pointed out in the comments, to prevent metadata from bubbling up to the main request, you should execute this in a new render context. You can do so by using the renderPlain method, rather than the usual render method (unless you're returning this from a controller, in which case use renderRoot instead).

$rendered = $render_service->renderPlain($build);
Source Link
Clive
  • 168k
  • 19
  • 303
  • 337

It was replaced with the renderer service:

$rendered = \Drupal::service('renderer')->render($renderArray);

The change record is slightly out of date; the method is render rather than renderElement these days.