public function BigPipeResponseAttachmentsProcessor::processAttachments in Drupal 10
Same name and namespace in other branches
- 8 core/modules/big_pipe/src/Render/BigPipeResponseAttachmentsProcessor.php \Drupal\big_pipe\Render\BigPipeResponseAttachmentsProcessor::processAttachments()
- 9 core/modules/big_pipe/src/Render/BigPipeResponseAttachmentsProcessor.php \Drupal\big_pipe\Render\BigPipeResponseAttachmentsProcessor::processAttachments()
File
- core/modules/big_pipe/src/Render/BigPipeResponseAttachmentsProcessor.php, line 60
Class
- BigPipeResponseAttachmentsProcessor
- Processes attachments of HTML responses with BigPipe enabled.
Namespace
Drupal\big_pipe\Render
Code
public function processAttachments(AttachmentsInterface $response) {
assert($response instanceof HtmlResponse);
try {
$response = $this
->renderPlaceholders($response);
} catch (EnforcedResponseException $e) {
return $e
->getResponse();
}
$attachments = $response
->getAttachments();
$big_pipe_placeholders = [];
$big_pipe_nojs_placeholders = [];
if (isset($attachments['big_pipe_placeholders'])) {
$big_pipe_placeholders = $attachments['big_pipe_placeholders'];
unset($attachments['big_pipe_placeholders']);
}
if (isset($attachments['big_pipe_nojs_placeholders'])) {
$big_pipe_nojs_placeholders = $attachments['big_pipe_nojs_placeholders'];
unset($attachments['big_pipe_nojs_placeholders']);
}
$html_response = clone $response;
$html_response
->setAttachments($attachments);
$processed_html_response = $this->htmlResponseAttachmentsProcessor
->processAttachments($html_response);
$attachments = $processed_html_response
->getAttachments();
$big_pipe_response = clone $processed_html_response;
if (count($big_pipe_placeholders)) {
$attachments['big_pipe_placeholders'] = $big_pipe_placeholders;
}
if (count($big_pipe_nojs_placeholders)) {
$attachments['big_pipe_nojs_placeholders'] = $big_pipe_nojs_placeholders;
}
$big_pipe_response
->setAttachments($attachments);
return $big_pipe_response;
}