diff --git a/core/authorize.php b/core/authorize.php index 22bede6f846..231ad8d629d 100644 --- a/core/authorize.php +++ b/core/authorize.php @@ -149,7 +149,7 @@ else { if (!empty($output)) { $response->headers->set('Content-Type', 'text/html; charset=utf-8'); - $response->setContent(\Drupal::service('bare_html_page_renderer')->renderMaintenancePage($output, $page_title, array( + $response->setContent(\Drupal::service('bare_html_page_renderer')->renderBarePage(['#markup' => $output], $page_title, 'maintenance_page', array( '#show_messages' => $show_messages, ))); $response->send(); diff --git a/core/includes/batch.inc b/core/includes/batch.inc index 59e15292969..088889dc3ea 100644 --- a/core/includes/batch.inc +++ b/core/includes/batch.inc @@ -135,7 +135,7 @@ function _batch_progress_page() { // additional HTML output by PHP shows up inside the page rather than below // it. While this causes invalid HTML, the same would be true if we didn't, // as content is not allowed to appear after anyway. - $fallback = \Drupal::service('bare_html_page_renderer')->renderMaintenancePage($fallback, $current_set['title'], array( + $fallback = \Drupal::service('bare_html_page_renderer')->renderBarePage(['#markup' => $fallback], $current_set['title'], 'maintenance_page', array( '#show_messages' => FALSE, )); list($fallback) = explode('', $fallback); diff --git a/core/includes/errors.inc b/core/includes/errors.inc index a3c356464ee..fbdb68c1de5 100644 --- a/core/includes/errors.inc +++ b/core/includes/errors.inc @@ -235,7 +235,7 @@ function _drupal_log_error($error, $fatal = FALSE) { install_display_output($output, $GLOBALS['install_state']); } else { - $output = \Drupal::service('bare_html_page_renderer')->renderMaintenancePage($message, 'Error'); + $output = \Drupal::service('bare_html_page_renderer')->renderBarePage(['#markup' => $message], 'Error', 'maintenance_page'); } $response = new Response($output, 500); diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 0899bec2a56..467374534e1 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -933,7 +933,7 @@ function install_display_output($output, $install_state) { 'ETag' => '"' . REQUEST_TIME . '"', ); $response->headers->add($default_headers); - $response->setContent(\Drupal::service('bare_html_page_renderer')->renderInstallPage($output, $output['#title'], $regions)); + $response->setContent(\Drupal::service('bare_html_page_renderer')->renderBarePage($output, $output['#title'], 'install_page', $regions)); $response->send(); exit; } diff --git a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php index 88fac223927..c8bc8b1ffa2 100644 --- a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php @@ -133,7 +133,7 @@ class DefaultExceptionSubscriber implements EventSubscriberInterface { } $content = $this->t('The website has encountered an error. Please try again later.'); - $output = $this->bareHtmlPageRenderer->renderMaintenancePage($content, $this->t('Error')); + $output = $this->bareHtmlPageRenderer->renderBarePage(['#markup' => $content], $this->t('Error'), 'maintenance_page'); $response = new Response($output); if ($exception instanceof HttpExceptionInterface) { diff --git a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php index 164dec0cadc..bdd05c7518a 100644 --- a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php @@ -105,7 +105,7 @@ class MaintenanceModeSubscriber implements EventSubscriberInterface { $content = Xss::filterAdmin(String::format($this->config->get('system.maintenance')->get('message'), array( '@site' => $this->config->get('system.site')->get('name'), ))); - $output = $this->bareHtmlPageRenderer->renderMaintenancePage($content, $this->t('Site under maintenance')); + $output = $this->bareHtmlPageRenderer->renderBarePage(['#markup' => $content], $this->t('Site under maintenance'), 'maintenance_page'); $response = new Response($output, 503); $event->setResponse($response); } diff --git a/core/lib/Drupal/Core/Render/BareHtmlPageRenderer.php b/core/lib/Drupal/Core/Render/BareHtmlPageRenderer.php index d744e1918a8..ca7aa1827a1 100644 --- a/core/lib/Drupal/Core/Render/BareHtmlPageRenderer.php +++ b/core/lib/Drupal/Core/Render/BareHtmlPageRenderer.php @@ -8,56 +8,19 @@ namespace Drupal\Core\Render; /** - * Default bare HTML page renderer + * Default bare HTML page renderer. */ class BareHtmlPageRenderer implements BareHtmlPageRendererInterface { /** * {@inheritdoc} */ - public function renderMaintenancePage($content, $title, array $page_additions = []) { - if (!is_array($content)) { - $content = ['#markup' => $content]; - } + public function renderBarePage(array $content, $title, $page_theme_property, array $page_additions = []) { $attributes = [ 'class' => [ - 'maintenance-page', + str_replace('_', '-', $page_theme_property), ], ]; - return $this->renderBarePage($content, $title, $page_additions, $attributes, 'maintenance_page'); - } - - /** - * {@inheritdoc} - */ - public function renderInstallPage($content, $title, array $page_additions = []) { - $attributes = [ - 'class' => [ - 'install-page', - ], - ]; - return $this->renderBarePage($content, $title, $page_additions, $attributes, 'install_page'); - } - - /** - * Renders a bare page. - * - * @param string|array $content - * The main content to render in the 'content' region. - * @param string $title - * The title for this maintenance page. - * @param array $page_additions - * Additional regions to add to the page. May also be used to pass the - * #show_messages property for #type 'page'. - * @param array $attributes - * Attributes to set on #type 'html'. - * @param string $page_theme_property - * The #theme property to set on #type 'page'. - * - * @return string - * The rendered HTML page. - */ - protected function renderBarePage(array $content, $title, array $page_additions, array $attributes, $page_theme_property) { $html = [ '#type' => 'html', '#attributes' => $attributes, diff --git a/core/lib/Drupal/Core/Render/BareHtmlPageRendererInterface.php b/core/lib/Drupal/Core/Render/BareHtmlPageRendererInterface.php index 7450199bd9a..e8b2c5e76e1 100644 --- a/core/lib/Drupal/Core/Render/BareHtmlPageRendererInterface.php +++ b/core/lib/Drupal/Core/Render/BareHtmlPageRendererInterface.php @@ -45,12 +45,14 @@ namespace Drupal\Core\Render; interface BareHtmlPageRendererInterface { /** - * Renders a "maintenance" page, styled as such. + * Renders a bare page. * - * @param string|array $content + * @param array $content * The main content to render in the 'content' region. * @param string $title * The title for this maintenance page. + * @param string $page_theme_property + * The #theme property to set on #type 'page'. * @param array $page_additions * Additional regions to add to the page. May also be used to pass the * #show_messages property for #type 'page'. @@ -58,22 +60,6 @@ interface BareHtmlPageRendererInterface { * @return string * The rendered HTML page. */ - public function renderMaintenancePage($content, $title, array $page_additions = []); - - /** - * Renders an "install" page, styled as such. - * - * @param string|array $content - * The main content to render in the 'content' region. - * @param string $title - * The title for this maintenance page. - * @param array $page_additions - * Additional regions to add to the page. May also be used to pass the - * #show_messages property for #type 'page'. - * - * @return string - * The rendered HTML page. - */ - public function renderInstallPage($content, $title, array $page_additions = []); + public function renderBarePage(array $content, $title, $page_theme_property, array $page_additions = []); } diff --git a/core/modules/system/src/Controller/DbUpdateController.php b/core/modules/system/src/Controller/DbUpdateController.php index cfd31dd8006..c3c25fac8f1 100644 --- a/core/modules/system/src/Controller/DbUpdateController.php +++ b/core/modules/system/src/Controller/DbUpdateController.php @@ -199,7 +199,7 @@ class DbUpdateController extends ControllerBase { } $title = isset($output['#title']) ? $output['#title'] : $this->t('Drupal database update'); - return new Response($this->bareHtmlPageRenderer->renderMaintenancePage($output, $title, $regions)); + return new Response($this->bareHtmlPageRenderer->renderBarePage($output, $title, 'maintenance_page', $regions)); } /**