function BigPipe::sendChunk

Same name in other branches
  1. 9 core/modules/big_pipe/src/Render/BigPipe.php \Drupal\big_pipe\Render\BigPipe::sendChunk()
  2. 10 core/modules/big_pipe/src/Render/BigPipe.php \Drupal\big_pipe\Render\BigPipe::sendChunk()
  3. 11.x core/modules/big_pipe/src/Render/BigPipe.php \Drupal\big_pipe\Render\BigPipe::sendChunk()

Sends a chunk.

Parameters

string|\Drupal\Core\Render\HtmlResponse $chunk: The string or response to append. String if there's no cacheability metadata or attachments to merge.

4 calls to BigPipe::sendChunk()
BigPipe::sendNoJsPlaceholders in core/modules/big_pipe/src/Render/BigPipe.php
Sends no-JS BigPipe placeholders' replacements as embedded HTML responses.
BigPipe::sendPlaceholders in core/modules/big_pipe/src/Render/BigPipe.php
Sends BigPipe placeholders' replacements as embedded AJAX responses.
BigPipe::sendPostBody in core/modules/big_pipe/src/Render/BigPipe.php
Sends </body> and everything after it.
BigPipe::sendPreBody in core/modules/big_pipe/src/Render/BigPipe.php
Sends everything until just before </body>.

File

core/modules/big_pipe/src/Render/BigPipe.php, line 258

Class

BigPipe
Service for sending an HTML response in chunks (to get faster page loads).

Namespace

Drupal\big_pipe\Render

Code

protected function sendChunk($chunk) {
    assert(is_string($chunk) || $chunk instanceof HtmlResponse);
    if ($chunk instanceof HtmlResponse) {
        print $chunk->getContent();
    }
    else {
        print $chunk;
    }
    flush();
}

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