class CalculatedPermissionsItem
Same name in other branches
- 10 core/lib/Drupal/Core/Session/CalculatedPermissionsItem.php \Drupal\Core\Session\CalculatedPermissionsItem
Represents a single entry for the calculated permissions.
Hierarchy
- class \Drupal\Core\Session\CalculatedPermissionsItem implements \Drupal\Core\Session\CalculatedPermissionsItemInterface
Expanded class hierarchy of CalculatedPermissionsItem
See also
\Drupal\Core\Session\ChainPermissionCalculator
9 files declare their use of CalculatedPermissionsItem
- AccessPolicyProcessorTest.php in core/
tests/ Drupal/ Tests/ Core/ Session/ AccessPolicyProcessorTest.php - CalculatedPermissionsItemTest.php in core/
tests/ Drupal/ Tests/ Core/ Session/ CalculatedPermissionsItemTest.php - CalculatedPermissionsTest.php in core/
tests/ Drupal/ Tests/ Core/ Session/ CalculatedPermissionsTest.php - InstallerAccessPolicy.php in core/
lib/ Drupal/ Core/ Installer/ InstallerAccessPolicy.php - PermissionCheckerTest.php in core/
tests/ Drupal/ Tests/ Core/ Session/ PermissionCheckerTest.php
File
-
core/
lib/ Drupal/ Core/ Session/ CalculatedPermissionsItem.php, line 10
Namespace
Drupal\Core\SessionView source
class CalculatedPermissionsItem implements CalculatedPermissionsItemInterface {
/**
* Constructs a new CalculatedPermissionsItem.
*
* @param string[] $permissions
* The permission names.
* @param bool $isAdmin
* (optional) Whether the item grants admin privileges.
* @param string $scope
* (optional) The scope name, defaults to 'drupal'.
* @param string|int $identifier
* (optional) The identifier within the scope, defaults to 'drupal'.
*/
public function __construct(array $permissions, bool $isAdmin = FALSE, string $scope = AccessPolicyInterface::SCOPE_DRUPAL, string|int $identifier = AccessPolicyInterface::SCOPE_DRUPAL) {
$this->permissions = $isAdmin ? [] : array_unique($permissions);
}
/**
* {@inheritdoc}
*/
public function getScope() : string {
return $this->scope;
}
/**
* {@inheritdoc}
*/
public function getIdentifier() : string|int {
return $this->identifier;
}
/**
* {@inheritdoc}
*/
public function getPermissions() : array {
return $this->permissions;
}
/**
* {@inheritdoc}
*/
public function isAdmin() : bool {
return $this->isAdmin;
}
/**
* {@inheritdoc}
*/
public function hasPermission(string $permission) : bool {
return $this->isAdmin() || in_array($permission, $this->permissions, TRUE);
}
}
Members
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.