trait CalculatedPermissionsTrait
Same name in other branches
- 10 core/lib/Drupal/Core/Session/CalculatedPermissionsTrait.php \Drupal\Core\Session\CalculatedPermissionsTrait
Trait for \Drupal\Core\Session\CalculatedPermissionsInterface.
Hierarchy
- trait \Drupal\Core\Session\CalculatedPermissionsTrait
File
-
core/
lib/ Drupal/ Core/ Session/ CalculatedPermissionsTrait.php, line 8
Namespace
Drupal\Core\SessionView source
trait CalculatedPermissionsTrait {
/**
* A list of calculated permission items, keyed by scope and identifier.
*
* @var array
*/
protected array $items = [];
/**
* {@inheritdoc}
*/
public function getItem(string $scope = AccessPolicyInterface::SCOPE_DRUPAL, string|int $identifier = AccessPolicyInterface::SCOPE_DRUPAL) : CalculatedPermissionsItemInterface|false {
return $this->items[$scope][$identifier] ?? FALSE;
}
/**
* {@inheritdoc}
*/
public function getItems() : array {
$item_sets = [];
foreach ($this->items as $scope_items) {
$item_sets[] = array_values($scope_items);
}
return array_merge(...$item_sets);
}
/**
* {@inheritdoc}
*/
public function getScopes() : array {
return array_keys($this->items);
}
/**
* {@inheritdoc}
*/
public function getItemsByScope(string $scope = AccessPolicyInterface::SCOPE_DRUPAL) : array {
return isset($this->items[$scope]) ? array_values($this->items[$scope]) : [];
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
CalculatedPermissionsTrait::$items | protected | property | A list of calculated permission items, keyed by scope and identifier. |
CalculatedPermissionsTrait::getItem | public | function | |
CalculatedPermissionsTrait::getItems | public | function | |
CalculatedPermissionsTrait::getItemsByScope | public | function | |
CalculatedPermissionsTrait::getScopes | public | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.