You are here

protected function MediaEmbed::renderIntoDomNode in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/media/src/Plugin/Filter/MediaEmbed.php \Drupal\media\Plugin\Filter\MediaEmbed::renderIntoDomNode()

Renders the given render array into the given DOM node.

Parameters

array $build: The render array to render in isolation.

\DOMNode $node: The DOM node to render into.

\Drupal\filter\FilterProcessResult $result: The accumulated result of filter processing, updated with the metadata bubbled during rendering.

1 call to MediaEmbed::renderIntoDomNode()
MediaEmbed::process in core/modules/media/src/Plugin/Filter/MediaEmbed.php
Performs the filter processing.

File

core/modules/media/src/Plugin/Filter/MediaEmbed.php, line 378

Class

MediaEmbed
Provides a filter to embed media items using a custom tag.

Namespace

Drupal\media\Plugin\Filter

Code

protected function renderIntoDomNode(array $build, \DOMNode $node, FilterProcessResult &$result) {

  // We need to render the embedded entity:
  // - without replacing placeholders, so that the placeholders are
  //   only replaced at the last possible moment. Hence we cannot use
  //   either renderPlain() or renderRoot(), so we must use render().
  // - without bubbling beyond this filter, because filters must
  //   ensure that the bubbleable metadata for the changes they make
  //   when filtering text makes it onto the FilterProcessResult
  //   object that they return ($result). To prevent that bubbling, we
  //   must wrap the call to render() in a render context.
  $markup = $this->renderer
    ->executeInRenderContext(new RenderContext(), function () use (&$build) {
    return $this->renderer
      ->render($build);
  });
  $result = $result
    ->merge(BubbleableMetadata::createFromRenderArray($build));
  static::replaceNodeContent($node, $markup);
}