You are here

protected static function BigPipeStrategy::generateBigPipePlaceholderId in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php \Drupal\big_pipe\Render\Placeholder\BigPipeStrategy::generateBigPipePlaceholderId()

Generates a BigPipe placeholder ID.

Parameters

string $original_placeholder: The original placeholder.

array $placeholder_render_array: The render array for a placeholder.

Return value

string The generated BigPipe placeholder ID.

2 calls to BigPipeStrategy::generateBigPipePlaceholderId()
BigPipeStrategy::createBigPipeJsPlaceholder in core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php
Creates a BigPipe JS placeholder.
BigPipeStrategy::createBigPipeNoJsPlaceholder in core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php
Creates a BigPipe no-JS placeholder.

File

core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php, line 273

Class

BigPipeStrategy
Defines the BigPipe placeholder strategy, to send HTML in chunks.

Namespace

Drupal\big_pipe\Render\Placeholder

Code

protected static function generateBigPipePlaceholderId($original_placeholder, array $placeholder_render_array) {

  // Generate a BigPipe placeholder ID (to be used by BigPipe's JavaScript).
  // @see \Drupal\Core\Render\PlaceholderGenerator::createPlaceholder()
  if (isset($placeholder_render_array['#lazy_builder'])) {
    $callback = $placeholder_render_array['#lazy_builder'][0];
    $arguments = $placeholder_render_array['#lazy_builder'][1];
    $token = Crypt::hashBase64(serialize($placeholder_render_array));
    return UrlHelper::buildQuery([
      'callback' => $callback,
      'args' => $arguments,
      'token' => $token,
    ]);
  }
  else {
    return Html::getId($original_placeholder);
  }
}