class AccessPolicyBase

Same name in other branches
  1. 10 core/lib/Drupal/Core/Session/AccessPolicyBase.php \Drupal\Core\Session\AccessPolicyBase

Base class for access policies.

Hierarchy

Expanded class hierarchy of AccessPolicyBase

2 files declare their use of AccessPolicyBase
AccessPolicyProcessorTest.php in core/tests/Drupal/Tests/Core/Session/AccessPolicyProcessorTest.php
InstallerAccessPolicy.php in core/lib/Drupal/Core/Installer/InstallerAccessPolicy.php

File

core/lib/Drupal/Core/Session/AccessPolicyBase.php, line 8

Namespace

Drupal\Core\Session
View source
abstract class AccessPolicyBase implements AccessPolicyInterface {
    
    /**
     * {@inheritdoc}
     */
    public function applies(string $scope) : bool {
        return $scope === AccessPolicyInterface::SCOPE_DRUPAL;
    }
    
    /**
     * {@inheritdoc}
     */
    public function calculatePermissions(AccountInterface $account, string $scope) : RefinableCalculatedPermissionsInterface {
        return (new RefinableCalculatedPermissions())->addCacheContexts($this->getPersistentCacheContexts());
    }
    
    /**
     * {@inheritdoc}
     */
    public function alterPermissions(AccountInterface $account, string $scope, RefinableCalculatedPermissionsInterface $calculated_permissions) : void {
    }
    
    /**
     * {@inheritdoc}
     */
    public function getPersistentCacheContexts() : array {
        return [];
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
AccessPolicyBase::alterPermissions public function Alter the permissions after all policies have finished building them. Overrides AccessPolicyInterface::alterPermissions 2
AccessPolicyBase::applies public function Checks whether this access policy applies to a given scope. Overrides AccessPolicyInterface::applies 7
AccessPolicyBase::calculatePermissions public function Calculates the permissions for an account within a given scope. Overrides AccessPolicyInterface::calculatePermissions 7
AccessPolicyBase::getPersistentCacheContexts public function Gets the persistent cache contexts. Overrides AccessPolicyInterface::getPersistentCacheContexts 9
AccessPolicyInterface::SCOPE_DRUPAL constant Scope ID for general Drupal access.

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