public function ViewSubscriber::onHtml

Processes a successful controller into an HTTP 200 response.

Some controllers may not return a response object but simply the body of one. The VIEW event is called in that case, to allow us to mutate that body into a Response object. In particular we assume that the return from an HTML-type response is a render array from a legacy page callback and render it.

Parameters

Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent $event: The Event to process.

File

drupal/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php, line 143
Definition of Drupal\Core\EventSubscriber\ViewSubscriber.

Class

ViewSubscriber
Main subscriber for VIEW HTTP responses.

Namespace

Drupal\Core\EventSubscriber

Code

public function onHtml(GetResponseForControllerResultEvent $event) {
  $page_callback_result = $event
    ->getControllerResult();
  return new Response(drupal_render_page($page_callback_result));
}