performPreSendTasks example

// First, gather the BigPipe placeholders that must be replaced.     $placeholders = $attachments['big_pipe_placeholders'] ?? [];
    $nojs_placeholders = $attachments['big_pipe_nojs_placeholders'] ?? [];

    // BigPipe sends responses using "Transfer-Encoding: chunked". To avoid     // sending already-sent assets, it is necessary to track cumulative assets     // from all previously rendered/sent chunks.     // @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.41     $cumulative_assets = AttachedAssets::createFromRenderArray(['#attached' => $attachments]);
    $cumulative_assets->setAlreadyLoadedLibraries($attachments['library']);

    $this->performPreSendTasks();

    // Find the closing </body> tag and get the strings before and after. But be     // careful to use the latest occurrence of the string "</body>", to ensure     // that strings in inline JavaScript or CDATA sections aren't used instead.     $parts = explode('</body>', $content);
    $post_body = array_pop($parts);
    $pre_body = implode('', $parts);

    $this->sendPreBody($pre_body$nojs_placeholders$cumulative_assets);
    $this->sendPlaceholders($placeholders$this->getPlaceholderOrder($pre_body$placeholders)$cumulative_assets);
    $this->sendPostBody($post_body);

    
Home | Imprint | This part of the site doesn't use cookies.