public function BigPipeSessionlessStrategy::processPlaceholders in Sessionless BigPipe 8
Same name and namespace in other branches
- 2.x src/Render/Placeholder/BigPipeSessionlessStrategy.php \Drupal\big_pipe_sessionless\Render\Placeholder\BigPipeSessionlessStrategy::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 BigPipeStrategy::processPlaceholders
File
- src/
Render/ Placeholder/ BigPipeSessionlessStrategy.php, line 38
Class
- BigPipeSessionlessStrategy
- Defines the BigPipe sessionless placeholder strategy, to send HTML in chunks.
Namespace
Drupal\big_pipe_sessionless\Render\PlaceholderCode
public function processPlaceholders(array $placeholders) {
$request = $this->requestStack
->getCurrentRequest();
// Sessionless BigPipe only acts on GET requests. It cannot act on HEAD
// requests, because \Symfony\Component\HttpFoundation\Response::prepare()
// sets a response's content to NULL for HEAD requests, which means
// \Drupal\big_pipe_sessionless\Render\BigPipeSessionless::sendContent() has
// no content to prime the Page Cache with.
if (!$request
->isMethod('GET')) {
return [];
}
// Routes can opt out from using the BigPipe HTML delivery technique.
if ($this->routeMatch
->getRouteObject()
->getOption('_no_big_pipe')) {
return [];
}
// @NOTE: We do exactly the opposite of parent::processPlaceholders().
// everything else in this method is identical to the parent method.
if ($this->sessionConfiguration
->hasSession($request)) {
return [];
}
return $this
->doProcessPlaceholders($placeholders);
}