This is a follow-up for #2352155: Remove HtmlFragment/HtmlPage.

dawehner and joelpittet at #2352155-75: Remove HtmlFragment/HtmlPage:

+++ b/core/lib/Drupal/Core/Render/BareHtmlPageRenderer.php
@@ -0,0 +1,80 @@
+  public function renderMaintenancePage($content, $title, array $page_additions = []) {
+    if (!is_array($content)) {
+      $content = ['#markup' => $content];
+    }
+    $attributes = [
+      'class' => [
+        'maintenance-page',
+      ],
+    ];
+    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');

The classes we'd like those on the templates.

After that there is literally not really a big difference.

Both @tim and @dawehner thinks that the concept of a bare html page should be not be connected with maintenancen or install itself.

Wim Leers at #2352155-78: Remove HtmlFragment/HtmlPage:

I agree that the concept of a "bare html page" should not be connected with the maintenance or install pages directly. I just couldn't think of a cleaner way to do this earlier.
And I still can't.

Because those classes that you'd like to see in the template… they can't live in the template, because they don't apply to the maintenance-page.html.twig template! They are meant to become classes on the <body> tag. And the tag is owned by html.html.twig, not maintenance-page.html.twig. Just like page.html.twig ends up in {{ page }} in html.html.twig, maintenance-page.html.twig and install-page.html.twig do, too.

Hence this reroll doesn't change that at all.

Also: this is still a big step forward in clarity/simplicity for rendering maintenance and install pages, so I don't believe we should hold this up over that.

dawehner at #2352155-83: Remove HtmlFragment/HtmlPage:

Well, the distinction could be made by the caller itself, well I don't want to block this really important patch for that,
so let's file a follow up and try to come up with a simpler solution in the future.

Comments

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new6.92 KB

Let's clean this up.

Status: Needs review » Needs work

The last submitted patch, 1: 2373735-1.patch, failed testing.

joelpittet’s picture

Issue summary: View changes
joelpittet’s picture

Issue summary: View changes
joelpittet’s picture

+++ b/core/lib/Drupal/Core/Render/BareHtmlPageRenderer.php
@@ -8,56 +8,22 @@
+  public function renderBarePage(array $content, $title, $page_theme_property, array $page_additions = []) {
...
+    if (!is_array($content)) {
+      $content = ['#markup' => $content];
+    }

These two things conflict it seems, can we fix all the places where it's a string or should we leave it as string|array and just leave the conversion with #markup?

dawehner’s picture

StatusFileSize
new6.87 KB
new2.38 KB

Yeah, let's just replace all the instances.

joelpittet’s picture

Status: Needs work » Needs review

Ok, testbot engage!

joelpittet’s picture

Status: Needs review » Needs work
+++ b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php
@@ -133,7 +133,7 @@ protected function onHtml(GetResponseForExceptionEvent $event) {
-    $output = $this->bareHtmlPageRenderer->renderBarePage($content, $this->t('Error'), 'maintenance_page');
+    $output = $this->bareHtmlPageRenderer->renderBarePage($content, ['#markup' => $this->t('Error')], 'maintenance_page');

whoops, Title may not need that just content in the first param's arg.

joelpittet’s picture

Status: Needs work » Needs review
StatusFileSize
new9.83 KB
new6.99 KB

Fixed

joelpittet’s picture

StatusFileSize
new995 bytes

I should read my interdiffs... before I post them.

The last submitted patch, 6: 2373735-6.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 9: simplify_clean_up-2373735-9.patch, failed testing.

joelpittet’s picture

Status: Needs work » Needs review
StatusFileSize
new2.15 KB
new8.87 KB

Adding the theme property.

wim leers’s picture

Status: Needs review » Needs work

Ok, testbot engage!

I don't know why, but this reminds me of Power Rangers :P


I only found two nitpicks:

  1. +++ b/core/authorize.php
    @@ -149,7 +149,7 @@ function authorize_access_allowed() {
    +  $response->setContent(\Drupal::service('bare_html_page_renderer')->renderBarePage(['#markup' => $output], $page_title, 'page', array(
    

    Shouldn't this be 'maintenance_page'?

  2. +++ b/core/lib/Drupal/Core/Render/BareHtmlPageRendererInterface.php
    @@ -45,12 +45,14 @@
        * @param string|array $content
    

    You changed the implementation to only accept array (YAY!) but not the docs :)

joelpittet’s picture

Status: Needs work » Needs review
StatusFileSize
new8.91 KB
new1.34 KB

Dang it was supposed to be a Star Trek TNG reference:P

#14.1 Thanks totally spaced on that one.

#14.2 Yeah I aim for working before changing other things instead of having an idea scrapped and wasting my time:) Now that we have green, lets do that too!

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Awesome! Thank you for fixing the issues with it @joelpittet

wim leers’s picture

RTBC++ :)

catch’s picture

Status: Reviewed & tested by the community » Fixed

This is a nice clean-up enabled by a recent critical (#2352155: Remove HtmlFragment/HtmlPage) so fine for what's allowed during beta.

Patch looks great. Committed/pushed to 8.0.x, thanks!

  • catch committed df19f0b on 8.0.x
    Issue #2373735 by joelpittet, dawehner: Simplify/clean up...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.