protected static function BigPipeStrategy::generateBigPipePlaceholderId in Drupal 10
Same name and namespace in other branches
- 8 core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php \Drupal\big_pipe\Render\Placeholder\BigPipeStrategy::generateBigPipePlaceholderId()
- 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.
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\PlaceholderCode
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'])) {
// Be sure cache contexts and tags are sorted before serializing them and
// making hash. Issue #3225328 removes sort from contexts and tags arrays
// for performances reasons.
if (isset($placeholder_render_array['#cache']['contexts'])) {
sort($placeholder_render_array['#cache']['contexts']);
}
if (isset($placeholder_render_array['#cache']['tags'])) {
sort($placeholder_render_array['#cache']['tags']);
}
$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);
}
}