You are here

public function BigPipeTestSubscriber::onRespondSetBigPipeDebugPlaceholderHeaders in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/big_pipe/tests/modules/big_pipe_test/src/EventSubscriber/BigPipeTestSubscriber.php \Drupal\big_pipe_test\EventSubscriber\BigPipeTestSubscriber::onRespondSetBigPipeDebugPlaceholderHeaders()
  2. 10 core/modules/big_pipe/tests/modules/big_pipe_test/src/EventSubscriber/BigPipeTestSubscriber.php \Drupal\big_pipe_test\EventSubscriber\BigPipeTestSubscriber::onRespondSetBigPipeDebugPlaceholderHeaders()

Exposes all BigPipe placeholders (JS and no-JS) via headers for testing.

Parameters

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

File

core/modules/big_pipe/tests/modules/big_pipe_test/src/EventSubscriber/BigPipeTestSubscriber.php, line 51

Class

BigPipeTestSubscriber

Namespace

Drupal\big_pipe_test\EventSubscriber

Code

public function onRespondSetBigPipeDebugPlaceholderHeaders(FilterResponseEvent $event) {
  $response = $event
    ->getResponse();
  if (!$response instanceof HtmlResponse) {
    return;
  }
  $attachments = $response
    ->getAttachments();
  $response->headers
    ->set('BigPipe-Test-Placeholders', '<none>');
  $response->headers
    ->set('BigPipe-Test-No-Js-Placeholders', '<none>');
  if (!empty($attachments['big_pipe_placeholders'])) {
    $response->headers
      ->set('BigPipe-Test-Placeholders', implode(' ', array_keys($attachments['big_pipe_placeholders'])));
  }
  if (!empty($attachments['big_pipe_nojs_placeholders'])) {
    $response->headers
      ->set('BigPipe-Test-No-Js-Placeholders', implode(' ', array_map('rawurlencode', array_keys($attachments['big_pipe_nojs_placeholders']))));
  }
}