3 namespace Drupal\Core\Render;
6 * Default bare HTML page renderer.
8 class BareHtmlPageRenderer implements BareHtmlPageRendererInterface {
11 * The renderer service.
13 * @var \Drupal\Core\Render\Renderer
18 * The HTML response attachments processor service.
20 * @var \Drupal\Core\Render\AttachmentsResponseProcessorInterface
22 protected $htmlResponseAttachmentsProcessor;
25 * Constructs a new BareHtmlPageRenderer.
27 * @param \Drupal\Core\Render\RendererInterface $renderer
28 * The renderer service.
29 * @param \Drupal\Core\Render\AttachmentsResponseProcessorInterface $html_response_attachments_processor
30 * The HTML response attachments processor service.
32 public function __construct(RendererInterface $renderer, AttachmentsResponseProcessorInterface $html_response_attachments_processor) {
33 $this->renderer = $renderer;
34 $this->htmlResponseAttachmentsProcessor = $html_response_attachments_processor;
40 public function renderBarePage(array $content, $title, $page_theme_property, array $page_additions = []) {
43 str_replace('_', '-', $page_theme_property),
48 '#attributes' => $attributes,
51 '#theme' => $page_theme_property,
53 'content' => $content,
57 // For backwards compatibility.
58 // @todo In Drupal 9, add a $show_messages function parameter.
59 if (!isset($page_additions['#show_messages']) || $page_additions['#show_messages'] === TRUE) {
60 $html['page']['highlighted'] = ['#type' => 'status_messages'];
63 // Add the bare minimum of attachments from the system module and the
64 // current maintenance theme.
65 system_page_attachments($html['page']);
66 $this->renderer->renderRoot($html);
68 $response = new HtmlResponse();
69 $response->setContent($html);
70 // Process attachments, because this does not go via the regular render
71 // pipeline, but will be sent directly.
72 $response = $this->htmlResponseAttachmentsProcessor->processAttachments($response);