You are here

public function PsrResponseSubscriber::onKernelView in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/EventSubscriber/PsrResponseSubscriber.php \Drupal\Core\EventSubscriber\PsrResponseSubscriber::onKernelView()
  2. 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\ViewEvent $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(ViewEvent $event) {
  $controller_result = $event
    ->getControllerResult();
  if ($controller_result instanceof ResponseInterface) {
    $event
      ->setResponse($this->httpFoundationFactory
      ->createResponse($controller_result));
  }
}