commit 7e810d0aa2390ca6da48d35983f8311c654634a1 Author: Joel Pittet Date: Tue Nov 18 06:59:01 2014 -0800 6 diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 0899bec..4673745 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 88fac22..1aac625 100644 --- a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php @@ -133,7 +133,7 @@ protected function onHtml(GetResponseForExceptionEvent $event) { } $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($content, ['#markup' => $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 164dec0..bdd05c7 100644 --- a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php @@ -105,7 +105,7 @@ public function onKernelRequestMaintenance(GetResponseEvent $event) { $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 a8904e6..20a0484 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 7450199..719c4bd 100644 --- a/core/lib/Drupal/Core/Render/BareHtmlPageRendererInterface.php +++ b/core/lib/Drupal/Core/Render/BareHtmlPageRendererInterface.php @@ -45,12 +45,14 @@ interface BareHtmlPageRendererInterface { /** - * Renders a "maintenance" page, styled as such. + * 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 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 @@ * @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 cfd31dd..c3c25fa 100644 --- a/core/modules/system/src/Controller/DbUpdateController.php +++ b/core/modules/system/src/Controller/DbUpdateController.php @@ -199,7 +199,7 @@ public function handle($op, Request $request) { } $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)); } /**