function HtmlResponseAttachmentsProcessor::renderHtmlResponseAttachmentPlaceholders

Same name in other branches
  1. 9 core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php \Drupal\Core\Render\HtmlResponseAttachmentsProcessor::renderHtmlResponseAttachmentPlaceholders()
  2. 8.9.x core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php \Drupal\Core\Render\HtmlResponseAttachmentsProcessor::renderHtmlResponseAttachmentPlaceholders()
  3. 10 core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php \Drupal\Core\Render\HtmlResponseAttachmentsProcessor::renderHtmlResponseAttachmentPlaceholders()

Renders HTML response attachment placeholders.

This is the last step where all of the attachments are placed into the response object's contents.

Parameters

\Drupal\Core\Render\HtmlResponse $response: The HTML response to update.

array $placeholders: An array of placeholders, keyed by type with the placeholders present in the content of the response as values.

array $variables: The variables to render and replace, keyed by type with renderable arrays as values.

1 call to HtmlResponseAttachmentsProcessor::renderHtmlResponseAttachmentPlaceholders()
HtmlResponseAttachmentsProcessor::processAttachments in core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php
Processes the attachments of a response that has attachments.

File

core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php, line 309

Class

HtmlResponseAttachmentsProcessor
Processes attachments of HTML responses.

Namespace

Drupal\Core\Render

Code

protected function renderHtmlResponseAttachmentPlaceholders(HtmlResponse $response, array $placeholders, array $variables) {
    $content = $response->getContent();
    foreach ($placeholders as $type => $placeholder) {
        if (isset($variables[$type])) {
            $content = str_replace($placeholder, $this->renderer
                ->renderInIsolation($variables[$type]), $content);
        }
    }
    $response->setContent($content);
}

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