class CalculatedGroupPermissionsItem in Group 2.0.x
Same name and namespace in other branches
- 8 src/Access/CalculatedGroupPermissionsItem.php \Drupal\group\Access\CalculatedGroupPermissionsItem
Represents a single entry for the calculated group permissions.
Hierarchy
- class \Drupal\group\Access\CalculatedGroupPermissionsItem implements CalculatedGroupPermissionsItemInterface
Expanded class hierarchy of CalculatedGroupPermissionsItem
See also
\Drupal\group\Access\ChainGroupPermissionCalculator
5 files declare their use of CalculatedGroupPermissionsItem
- CalculatedGroupPermissionsItemTest.php in tests/
src/ Unit/ CalculatedGroupPermissionsItemTest.php - CalculatedGroupPermissionsTest.php in tests/
src/ Unit/ CalculatedGroupPermissionsTest.php - GroupPermissionCheckerTest.php in tests/
src/ Unit/ GroupPermissionCheckerTest.php - GroupPermissionHashGeneratorTest.php in tests/
src/ Unit/ GroupPermissionHashGeneratorTest.php - RefinableCalculatedGroupPermissionsTest.php in tests/
src/ Unit/ RefinableCalculatedGroupPermissionsTest.php
File
- src/
Access/ CalculatedGroupPermissionsItem.php, line 10
Namespace
Drupal\group\AccessView source
class CalculatedGroupPermissionsItem implements CalculatedGroupPermissionsItemInterface {
/**
* The scope name.
*
* @var string
*/
protected $scope;
/**
* The identifier.
*
* @var string|int
*/
protected $identifier;
/**
* The permission names.
*
* @var string[]
*/
protected $permissions;
/**
* Whether this entry grants admin rights for the given scope.
*
* @var bool
*/
protected $isAdmin;
/**
* Constructs a new CalculatedGroupPermissionsItem.
*
* @param string $scope
* The scope name.
* @param string|int $identifier
* The identifier within the scope.
* @param string[] $permissions
* The permission names.
* @param bool $is_admin
* (optional) Whether the item grants admin privileges.
*/
public function __construct($scope, $identifier, $permissions, $is_admin = NULL) {
$this->scope = $scope;
$this->identifier = $identifier;
$this->permissions = array_unique($permissions);
// @todo Rework for group 8.2.x to no longer use the admin permission.
// @todo Do make flag default to FALSE and pass role's isAdmin flag instead.
$this->isAdmin = isset($is_admin) ? $is_admin : in_array('administer group', $permissions, TRUE);
}
/**
* {@inheritdoc}
*/
public function getScope() {
return $this->scope;
}
/**
* {@inheritdoc}
*/
public function getIdentifier() {
return $this->identifier;
}
/**
* {@inheritdoc}
*/
public function getPermissions() {
return $this->permissions;
}
/**
* {@inheritdoc}
*/
public function isAdmin() {
return $this->isAdmin;
}
/**
* {@inheritdoc}
*/
public function hasPermission($permission) {
return $this
->isAdmin() || in_array($permission, $this->permissions, TRUE);
}
}