You are here

public function EventSubscriber::onResponse in JS Callback Handler 8.3

Renders the ajax commands right before preparing the result.

Parameters

\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event: The response event, which contains the possible AjaxResponse object.

File

src/EventSubscriber.php, line 98

Class

EventSubscriber
RouteSubscriber.

Namespace

Drupal\js

Code

public function onResponse(FilterResponseEvent $event) {
  $response = $event
    ->getResponse();
  if ($response instanceof JsResponse) {
    $this->jsAttachmentsProcessor
      ->processAttachments($response);

    // Correct mime type.
    $response
      ->setHeader('Content-Type', $response
      ->getMimeType() . '; charset=utf-8');
  }
}