function BarAlterAccessPolicy::alterPermissions
Same name in other branches
- 10 core/tests/Drupal/Tests/Core/Session/AccessPolicyProcessorTest.php \Drupal\Tests\Core\Session\BarAlterAccessPolicy::alterPermissions()
Overrides AccessPolicyBase::alterPermissions
File
-
core/
tests/ Drupal/ Tests/ Core/ Session/ AccessPolicyProcessorTest.php, line 480
Class
Namespace
Drupal\Tests\Core\SessionCode
public function alterPermissions(AccountInterface $account, string $scope, RefinableCalculatedPermissionsInterface $calculated_permissions) : void {
parent::alterPermissions($account, $scope, $calculated_permissions);
foreach ($calculated_permissions->getItemsByScope($scope) as $item) {
$permissions = $item->getPermissions();
if (($key = array_search('bar', $permissions, TRUE)) !== FALSE) {
$permissions[$key] = 'baz';
$new_item = new CalculatedPermissionsItem($permissions, FALSE, $item->getScope(), $item->getIdentifier());
$calculated_permissions->addItem($new_item, TRUE);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.