W3cubDocs

/Drupal 8

protected function HtmlResponseAttachmentsProcessor::renderHtmlResponseAttachmentPlaceholders

protected HtmlResponseAttachmentsProcessor::renderHtmlResponseAttachmentPlaceholders(HtmlResponse $response, array $placeholders, array $variables)

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.

File

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

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->renderPlain($variables[$type]), $content);
    }
  }
  $response->setContent($content);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!HtmlResponseAttachmentsProcessor.php/function/HtmlResponseAttachmentsProcessor::renderHtmlResponseAttachmentPlaceholders/8.1.x