function CalculatedPermissions::__construct

Same name in other branches
  1. 11.x core/lib/Drupal/Core/Session/CalculatedPermissions.php \Drupal\Core\Session\CalculatedPermissions::__construct()

Constructs a new CalculatedPermissions.

Parameters

\Drupal\Core\Session\CalculatedPermissionsInterface $source: The calculated permission to create a value object from.

File

core/lib/Drupal/Core/Session/CalculatedPermissions.php, line 23

Class

CalculatedPermissions
Represents a calculated set of permissions with cacheable metadata.

Namespace

Drupal\Core\Session

Code

public function __construct(CalculatedPermissionsInterface $source) {
    foreach ($source->getItems() as $item) {
        $this->items[$item->getScope()][$item->getIdentifier()] = $item;
    }
    $this->setCacheability($source);
    // The (persistent) cache contexts attached to the permissions are only
    // used internally to store the permissions in the VariationCache. We strip
    // these cache contexts when the calculated permissions get converted into a
    // value object here so that they will never bubble up by accident.
    $this->cacheContexts = [];
}

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