function BigPipeStrategy::createBigPipeNoJsPlaceholder

Same name in other branches
  1. 9 core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php \Drupal\big_pipe\Render\Placeholder\BigPipeStrategy::createBigPipeNoJsPlaceholder()
  2. 8.9.x core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php \Drupal\big_pipe\Render\Placeholder\BigPipeStrategy::createBigPipeNoJsPlaceholder()
  3. 11.x core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php \Drupal\big_pipe\Render\Placeholder\BigPipeStrategy::createBigPipeNoJsPlaceholder()

Creates a BigPipe no-JS placeholder.

Parameters

string $original_placeholder: The original placeholder.

array $placeholder_render_array: The render array for a placeholder.

bool $placeholder_must_be_attribute_safe: Whether the placeholder must be safe for use in an HTML attribute (in case it's a placeholder for an HTML attribute value or a subset of it).

Return value

array The resulting BigPipe no-JS placeholder render array.

1 call to BigPipeStrategy::createBigPipeNoJsPlaceholder()
BigPipeStrategy::doProcessPlaceholders in core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php
Transforms placeholders to BigPipe placeholders, either no-JS or JS.

File

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

Class

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

Namespace

Drupal\big_pipe\Render\Placeholder

Code

protected static function createBigPipeNoJsPlaceholder($original_placeholder, array $placeholder_render_array, $placeholder_must_be_attribute_safe = FALSE) {
    if (!$placeholder_must_be_attribute_safe) {
        $big_pipe_placeholder = '<span data-big-pipe-nojs-placeholder-id="' . Html::escape(static::generateBigPipePlaceholderId($original_placeholder, $placeholder_render_array)) . '"></span>';
    }
    else {
        $big_pipe_placeholder = 'big_pipe_nojs_placeholder_attribute_safe:' . Html::escape($original_placeholder);
    }
    return [
        '#markup' => $big_pipe_placeholder,
        '#cache' => [
            'max-age' => 0,
            'contexts' => [
                'session.exists',
            ],
        ],
        '#attached' => [
            'big_pipe_nojs_placeholders' => [
                $big_pipe_placeholder => $placeholder_render_array,
            ],
        ],
    ];
}

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