8.4.x BareHtmlPageRenderer.php public BareHtmlPageRenderer::renderBarePage(array $content, $title, $page_theme_property, array $page_additions = [])
8.0.x BareHtmlPageRenderer.php public BareHtmlPageRenderer::renderBarePage(array $content, $title, $page_theme_property, array $page_additions = [])
8.1.x BareHtmlPageRenderer.php public BareHtmlPageRenderer::renderBarePage(array $content, $title, $page_theme_property, array $page_additions = [])
8.2.x BareHtmlPageRenderer.php public BareHtmlPageRenderer::renderBarePage(array $content, $title, $page_theme_property, array $page_additions = [])
8.3.x BareHtmlPageRenderer.php public BareHtmlPageRenderer::renderBarePage(array $content, $title, $page_theme_property, array $page_additions = [])
8.5.x BareHtmlPageRenderer.php BareHtmlPageRenderer::renderBarePage(array $content, $title, $page_theme_property, array $page_additions = [])
8.5.x BareHtmlPageRenderer.php BareHtmlPageRenderer::renderBarePage(array $content, $title, $page_theme_property, array $page_additions = array())

Renders a bare page.

Parameters

array $content: The main content to render in the 'content' region.

string $title: The title for this maintenance page.

string $page_theme_property: The #theme property to set on #type 'page'.

array $page_additions: Additional regions to add to the page. May also be used to pass the #show_messages property for #type 'page'.

Return value

\Drupal\Core\Render\HtmlResponse The rendered HTML response, ready to be sent.

Overrides BareHtmlPageRendererInterface::renderBarePage

File

core/lib/Drupal/Core/Render/BareHtmlPageRenderer.php, line 40

Class

BareHtmlPageRenderer
Default bare HTML page renderer.

Namespace

Drupal\Core\Render

Code

public function renderBarePage(array $content, $title, $page_theme_property, array $page_additions = []) {
  $attributes = [
    'class' => [
      str_replace('_', '-', $page_theme_property),
    ],
  ];
  $html = [
    '#type' => 'html',
    '#attributes' => $attributes,
    'page' => [
      '#type' => 'page',
      '#theme' => $page_theme_property,
      '#title' => $title,
      'content' => $content,
    ] + $page_additions,
  ];

  // For backwards compatibility.
  // @todo In Drupal 9, add a $show_messages function parameter.
  if (!isset($page_additions['#show_messages']) || $page_additions['#show_messages'] === TRUE) {
    $html['page']['highlighted'] = ['#type' => 'status_messages'];
  }

  // Add the bare minimum of attachments from the system module and the
  // current maintenance theme.
  system_page_attachments($html['page']);
  $this->renderer->renderRoot($html);

  $response = new HtmlResponse();
  $response->setContent($html);
  // Process attachments, because this does not go via the regular render
  // pipeline, but will be sent directly.
  $response = $this->htmlResponseAttachmentsProcessor->processAttachments($response);
  return $response;
}