Follow-up to and postponed on #2272279: Kill RenderWrapper class

From Fabianx #2272279-27: Kill RenderWrapper class:

So in my book this would be **RTBC** and this all looks great, but if @Crell still disagrees with polluting the core HtmlPage.php, my take is to use a decorator that only exposes the right methods we want themers to use:

use Drupal\Core\Template\HtmlPageDecorator;
[...]
$variables['page'] = new HtmlPageDecorator($page);
[...]
class HtmlPageDecorator implements ... {
protected $page;
public function getStyles() {
}
[...]
etc.
}

This can then either call drupal_get_css directly or call up to the wrapped object - no pollution all the nice DX and TX (themer experience).

Very little changes from this patch and using a known pattern to 'represent an object in a different way to the user of it'.

Comments

sun’s picture

I don't understand why we need a decorator for this?

Styles and scripts are as fundamental to a HTML page as meta tags and links as well as the title and body.

mgifford’s picture

Status: Postponed » Active
catch’s picture

Status: Active » Closed (duplicate)