class AlwaysAddsAccessPolicy

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Session/AccessPolicyProcessorTest.php \Drupal\Tests\Core\Session\AlwaysAddsAccessPolicy
  2. 10 core/tests/Drupal/Tests/Core/Session/AccessPolicyProcessorTest.php \Drupal\Tests\Core\Session\AlwaysAddsAccessPolicy

A test access policy that adds a permission.

Hierarchy

Expanded class hierarchy of AlwaysAddsAccessPolicy

File

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

Namespace

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

}

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