class CalculatedPermissions

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

Represents a calculated set of permissions with cacheable metadata.

Hierarchy

Expanded class hierarchy of CalculatedPermissions

See also

\Drupal\core\Session\AccessPolicyProcessor

4 files declare their use of CalculatedPermissions
AccessPolicyProcessorTest.php in core/tests/Drupal/Tests/Core/Session/AccessPolicyProcessorTest.php
CalculatedPermissionsTest.php in core/tests/Drupal/Tests/Core/Session/CalculatedPermissionsTest.php
PermissionCheckerTest.php in core/tests/Drupal/Tests/Core/Session/PermissionCheckerTest.php
PermissionsHashGeneratorTest.php in core/tests/Drupal/Tests/Core/Session/PermissionsHashGeneratorTest.php

File

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

Namespace

Drupal\Core\Session
View source
class CalculatedPermissions implements CalculatedPermissionsInterface {
    use CacheableDependencyTrait;
    use CalculatedPermissionsTrait;
    
    /**
     * Constructs a new CalculatedPermissions.
     *
     * @param \Drupal\Core\Session\CalculatedPermissionsInterface $source
     *   The calculated permission to create a value object from.
     */
    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 = [];
    }

}

Members

Title Sort descending Modifiers Object type Summary Overrides
CacheableDependencyTrait::$cacheContexts protected property Cache contexts.
CacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
CacheableDependencyTrait::$cacheTags protected property Cache tags.
CacheableDependencyTrait::getCacheContexts public function 4
CacheableDependencyTrait::getCacheMaxAge public function 4
CacheableDependencyTrait::getCacheTags public function 4
CacheableDependencyTrait::setCacheability protected function Sets cacheability; useful for value object constructors.
CalculatedPermissions::__construct public function Constructs a new CalculatedPermissions.
CalculatedPermissionsTrait::$items protected property A list of calculated permission items, keyed by scope and identifier.
CalculatedPermissionsTrait::getItem public function
CalculatedPermissionsTrait::getItems public function
CalculatedPermissionsTrait::getItemsByScope public function
CalculatedPermissionsTrait::getScopes public function

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