You are here

protected function ChainGroupPermissionCalculator::getPersistentCacheContexts in Group 8

Same name and namespace in other branches
  1. 2.0.x src/Access/ChainGroupPermissionCalculator.php \Drupal\group\Access\ChainGroupPermissionCalculator::getPersistentCacheContexts()

Performs the retrieval of persistent cache contexts.

Parameters

string $constant_name: The constant to read from each calculator.

Return value

string[] The combined persistent cache contexts from all calculators.

3 calls to ChainGroupPermissionCalculator::getPersistentCacheContexts()
ChainGroupPermissionCalculator::getPersistentAnonymousCacheContexts in src/Access/ChainGroupPermissionCalculator.php
Gets the cache contexts that always apply to the anonymous permissions.
ChainGroupPermissionCalculator::getPersistentMemberCacheContexts in src/Access/ChainGroupPermissionCalculator.php
Gets the cache contexts that always apply to the member permissions.
ChainGroupPermissionCalculator::getPersistentOutsiderCacheContexts in src/Access/ChainGroupPermissionCalculator.php
Gets the cache contexts that always apply to the outsider permissions.

File

src/Access/ChainGroupPermissionCalculator.php, line 219

Class

ChainGroupPermissionCalculator
Collects group permissions for an account.

Namespace

Drupal\group\Access

Code

protected function getPersistentCacheContexts($constant_name) {
  $cid = 'group_permission:chain_calculator:contexts:' . $constant_name;

  // Retrieve the contexts from the regular static cache if available.
  if ($static_cache = $this->regularStatic
    ->get($cid)) {
    $contexts = $static_cache->data;
  }
  else {
    $contexts = [];
    foreach ($this
      ->getCalculators() as $calculator) {
      $contexts = array_merge($contexts, constant(get_class($calculator) . '::' . $constant_name));
    }

    // Store the contexts in the regular static cache.
    $this->regularStatic
      ->set($cid, $contexts);
  }
  return $contexts;
}