AccessPolicyBase.php

Same filename in other branches
  1. 11.x core/lib/Drupal/Core/Session/AccessPolicyBase.php

Namespace

Drupal\Core\Session

File

core/lib/Drupal/Core/Session/AccessPolicyBase.php

View source
<?php

namespace Drupal\Core\Session;


/**
 * Base class for access policies.
 */
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 [];
    }

}

Classes

Title Deprecated Summary
AccessPolicyBase Base class for access policies.

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