class MainContentViewSubscriber implements EventSubscriberInterface (View source)

View subscriber rendering main content render arrays into responses.

Additional target rendering formats can be defined by adding another service that implements \Drupal\Core\Render\MainContent\MainContentRendererInterface and tagging it as a @code render.main_content_renderer @endcode, then \Drupal\Core\Render\MainContent\MainContentRenderersPass will detect it and use it when appropriate.

Constants

WRAPPER_FORMAT

URL query attribute to indicate the wrapper used to render a request.

The wrapper format determines how the HTML is wrapped, for example in a modal dialog.

Properties

protected ControllerResolverInterface $classResolver

The class resolver service.

protected RouteMatchInterface $routeMatch

The current route match.

protected array $mainContentRenderers

The available main content renderer services, keyed per format.

Methods

__construct(ClassResolverInterface $class_resolver, RouteMatchInterface $route_match, array $main_content_renderers)

Constructs a new MainContentViewSubscriber object.

onViewRenderArray(ViewEvent $event)

Sets a response given a (main content) render array.

static 
getSubscribedEvents()

{@inheritdoc}

Details

__construct(ClassResolverInterface $class_resolver, RouteMatchInterface $route_match, array $main_content_renderers)

Constructs a new MainContentViewSubscriber object.

Parameters

ClassResolverInterface $class_resolver

The class resolver service.

RouteMatchInterface $route_match

The current route match.

array $main_content_renderers

The available main content renderer service IDs, keyed by format.

onViewRenderArray(ViewEvent $event)

Sets a response given a (main content) render array.

Parameters

ViewEvent $event

The event to process.

static getSubscribedEvents()

{@inheritdoc}