class SuperUserAccessPolicy

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

Grants user 1 an all access pass.

Hierarchy

Expanded class hierarchy of SuperUserAccessPolicy

1 file declares its use of SuperUserAccessPolicy
SuperUserAccessPolicyTest.php in core/tests/Drupal/Tests/Core/Session/SuperUserAccessPolicyTest.php
1 string reference to 'SuperUserAccessPolicy'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses SuperUserAccessPolicy
access_policy.super_user in core/core.services.yml
Drupal\Core\Session\SuperUserAccessPolicy

File

core/lib/Drupal/Core/Session/SuperUserAccessPolicy.php, line 10

Namespace

Drupal\Core\Session
View source
final class SuperUserAccessPolicy extends AccessPolicyBase {
    
    /**
     * {@inheritdoc}
     */
    public function calculatePermissions(AccountInterface $account, string $scope) : RefinableCalculatedPermissionsInterface {
        $calculated_permissions = parent::calculatePermissions($account, $scope);
        if ((int) $account->id() !== 1) {
            return $calculated_permissions;
        }
        return $calculated_permissions->addItem(new CalculatedPermissionsItem([], TRUE));
    }
    
    /**
     * {@inheritdoc}
     */
    public function getPersistentCacheContexts() : array {
        return [
            'user.is_super_user',
        ];
    }

}

Members


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