class HtmlRenderer implements MainContentRendererInterface (View source)

Default main content renderer for HTML requests.

For attachment handling of HTML responses:

Properties

protected TitleResolverInterface $titleResolver

The title resolver.

protected PluginManagerInterface $displayVariantManager

The display variant manager.

protected EventDispatcherInterface $eventDispatcher

The event dispatcher.

protected ModuleHandlerInterface $moduleHandler

The module handler.

protected RendererInterface $renderer

The renderer service.

protected RenderCacheInterface $renderCache

The render cache service.

protected array $rendererConfig

The renderer configuration array.

protected ThemeManagerInterface $themeManager

The theme manager.

Methods

__construct(TitleResolverInterface $title_resolver, PluginManagerInterface $display_variant_manager, EventDispatcherInterface $event_dispatcher, ModuleHandlerInterface $module_handler, RendererInterface $renderer, RenderCacheInterface $render_cache, array $renderer_config, ThemeManagerInterface $theme_manager = NULL)

Constructs a new HtmlRenderer.

Response
renderResponse(array $main_content, Request $request, RouteMatchInterface $route_match)

Renders the main content render array into a response.

array
prepare(array $main_content, Request $request, RouteMatchInterface $route_match)

Prepares the HTML body: wraps the main content in #type 'page'.

invokePageAttachmentHooks(array $page)

Invokes the page attachment hooks.

buildPageTopAndBottom(array $html)

Invokes the page top and bottom hooks.

Details

__construct(TitleResolverInterface $title_resolver, PluginManagerInterface $display_variant_manager, EventDispatcherInterface $event_dispatcher, ModuleHandlerInterface $module_handler, RendererInterface $renderer, RenderCacheInterface $render_cache, array $renderer_config, ThemeManagerInterface $theme_manager = NULL)

Constructs a new HtmlRenderer.

Parameters

TitleResolverInterface $title_resolver

The title resolver.

PluginManagerInterface $display_variant_manager

The display variant manager.

EventDispatcherInterface $event_dispatcher

The event dispatcher.

ModuleHandlerInterface $module_handler

The module handler.

RendererInterface $renderer

The renderer service.

RenderCacheInterface $render_cache

The render cache service.

array $renderer_config

The renderer configuration array.

ThemeManagerInterface $theme_manager

The theme manager.

Response renderResponse(array $main_content, Request $request, RouteMatchInterface $route_match)

Renders the main content render array into a response.

Parameters

array $main_content

The render array representing the main content.

Request $request

The request object, for context.

RouteMatchInterface $route_match

The route match, for context.

Return Value

Response

The Response in the format that this implementation supports.

protected array prepare(array $main_content, Request $request, RouteMatchInterface $route_match)

Prepares the HTML body: wraps the main content in #type 'page'.

Parameters

array $main_content

The render array representing the main content.

Request $request

The request object, for context.

RouteMatchInterface $route_match

The route match, for context.

Return Value

array

An array with two values:

  1. A #type 'page' render array.
  2. The page title.

Exceptions

LogicException

invokePageAttachmentHooks(array $page)

internal  
 

Invokes the page attachment hooks.

Parameters

array $page

A #type 'page' render array, for which the page attachment hooks will be invoked and to which the results will be added.

Exceptions

LogicException

See also

hook_page_attachments()
hook_page_attachments_alter()

buildPageTopAndBottom(array $html)

internal  
 

Invokes the page top and bottom hooks.

Parameters

array $html

A #type 'html' render array, for which the page top and bottom hooks will be invoked, and to which the 'page_top' and 'page_bottom' children (also render arrays) will be added (if non-empty).

Exceptions

LogicException

See also

hook_page_top()
hook_page_bottom()
html.html.twig