function MediaEmbed::renderIntoDomNode

Same name in other branches
  1. 9 core/modules/media/src/Plugin/Filter/MediaEmbed.php \Drupal\media\Plugin\Filter\MediaEmbed::renderIntoDomNode()
  2. 10 core/modules/media/src/Plugin/Filter/MediaEmbed.php \Drupal\media\Plugin\Filter\MediaEmbed::renderIntoDomNode()
  3. 11.x 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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.