You are here

public function BigPipeStrategy::processPlaceholders in Drupal 9

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

Processes placeholders to render them with different strategies.

Parameters

array $placeholders: The placeholders to process, with the keys being the markup for the placeholders and the values the corresponding render array describing the data to be rendered.

Return value

array The resulting placeholders, with a subset of the keys of $placeholders (and those being the markup for the placeholders) but with the corresponding render array being potentially modified to render e.g. an ESI or BigPipe placeholder.

Overrides PlaceholderStrategyInterface::processPlaceholders

File

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

Class

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

Namespace

Drupal\big_pipe\Render\Placeholder

Code

public function processPlaceholders(array $placeholders) {
  $request = $this->requestStack
    ->getCurrentRequest();

  // @todo remove this check when https://www.drupal.org/node/2367555 lands.
  if (!$request
    ->isMethodCacheable()) {
    return [];
  }

  // Routes can opt out from using the BigPipe HTML delivery technique.
  if ($this->routeMatch
    ->getRouteObject()
    ->getOption('_no_big_pipe')) {
    return [];
  }
  if (!$this->sessionConfiguration
    ->hasSession($request)) {
    return [];
  }
  return $this
    ->doProcessPlaceholders($placeholders);
}