class FooAccessPolicy

Same name in other branches
  1. 10 core/tests/Drupal/Tests/Core/Session/AccessPolicyProcessorTest.php \Drupal\Tests\Core\Session\FooAccessPolicy

Hierarchy

Expanded class hierarchy of FooAccessPolicy

File

core/tests/Drupal/Tests/Core/Session/AccessPolicyProcessorTest.php, line 423

Namespace

Drupal\Tests\Core\Session
View source
class FooAccessPolicy extends AccessPolicyBase {
    public function applies(string $scope) : bool {
        return $scope === 'foo' || $scope === 'anything';
    }
    public function calculatePermissions(AccountInterface $account, string $scope) : RefinableCalculatedPermissionsInterface {
        $calculated_permissions = parent::calculatePermissions($account, $scope);
        return $calculated_permissions->addItem(new CalculatedPermissionsItem([
            'foo',
            'bar',
        ], TRUE, $scope, 1));
    }
    public function getPersistentCacheContexts() : array {
        return [
            'foo',
        ];
    }

}

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
AccessPolicyInterface::SCOPE_DRUPAL constant Scope ID for general Drupal access.
FooAccessPolicy::applies public function Checks whether this access policy applies to a given scope. Overrides AccessPolicyBase::applies
FooAccessPolicy::calculatePermissions public function Calculates the permissions for an account within a given scope. Overrides AccessPolicyBase::calculatePermissions
FooAccessPolicy::getPersistentCacheContexts public function Gets the persistent cache contexts. Overrides AccessPolicyBase::getPersistentCacheContexts

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