function PsrResponseSubscriber::onKernelView

Same name in other branches
  1. 9 core/lib/Drupal/Core/EventSubscriber/PsrResponseSubscriber.php \Drupal\Core\EventSubscriber\PsrResponseSubscriber::onKernelView()
  2. 8.9.x core/lib/Drupal/Core/EventSubscriber/PsrResponseSubscriber.php \Drupal\Core\EventSubscriber\PsrResponseSubscriber::onKernelView()
  3. 11.x 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));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.