You are here

protected function BaseContext::populateCache in Acquia Lift Connector 8.4

Same name and namespace in other branches
  1. 8.3 src/Service/Context/BaseContext.php \Drupal\acquia_lift\Service\Context\BaseContext::populateCache()

Populate page's cache context.

Parameters

&$page: The page that is to be populated.

1 call to BaseContext::populateCache()
BaseContext::populate in src/Service/Context/BaseContext.php
Populate page by context.

File

src/Service/Context/BaseContext.php, line 64

Class

BaseContext

Namespace

Drupal\acquia_lift\Service\Context

Code

protected function populateCache(&$page) {

  // Set cache contexts.
  foreach ($this->cacheContexts as $context) {
    $page['#cache']['contexts'][] = $context;
  }

  // Guard from a possible case that cache contexts contain duplicate items.
  if (isset($page['#cache']['contexts'])) {
    $page['#cache']['contexts'] = array_unique($page['#cache']['contexts']);
  }
}