/**
  * {@inheritdoc}
  */
 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;
 }
 /**
  * Renders form and status messages and returns an ajax response.
  *
  * Used for both submission buttons.
  *
  * @param array $form
  *   The form.
  *
  * @return \Drupal\Core\Ajax\AjaxResponse
  *   An ajax response to replace the form.
  */
 protected function ajaxRenderFormAndMessages(array &$form)
 {
     $response = new AjaxResponse();
     // Retrieve the element to be rendered.
     $status_messages = ['#type' => 'status_messages', '#weight' => -10];
     // For some crazy reason, if we do this inline in the replace command, it
     // breaks ajax functionality entirely.
     $output = $this->renderer->renderRoot($form);
     $messages = $this->renderer->renderRoot($status_messages);
     $message_wrapper_id = '#' . self::MESSAGE_WRAPPER_ID;
     $response->setAttachments($form['#attached']);
     $response->addCommand(new ReplaceCommand(NULL, $output));
     $response->addCommand(new HtmlCommand($message_wrapper_id, ''));
     $response->addCommand(new AppendCommand($message_wrapper_id, $messages));
     return $response;
 }