You are here

public function PsrResponseSubscriber::onKernelView in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/EventSubscriber/PsrResponseSubscriber.php \Drupal\Core\EventSubscriber\PsrResponseSubscriber::onKernelView()

Converts a PSR-7 response to a Symfony response.

Parameters

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

File

core/lib/Drupal/Core/EventSubscriber/PsrResponseSubscriber.php, line 40

Class

PsrResponseSubscriber
Response subscriber for handling PSR-7 responses.

Namespace

Drupal\Core\EventSubscriber

Code

public function onKernelView(GetResponseForControllerResultEvent $event) {
  $controller_result = $event
    ->getControllerResult();
  if ($controller_result instanceof ResponseInterface) {
    $event
      ->setResponse($this->httpFoundationFactory
      ->createResponse($controller_result));
  }
}