public function GroupRoleInterface::changePermissions in Group 2.0.x
Same name and namespace in other branches
- 8 src/Entity/GroupRoleInterface.php \Drupal\group\Entity\GroupRoleInterface::changePermissions()
Changes permissions for the role.
This function may be used to grant and revoke multiple permissions at once. For example, when a form exposes checkboxes to configure permissions for a role, the form submit handler may directly pass the submitted values for the checkboxes form element to this function.
Parameters
array $permissions: (optional) An associative array, where the key holds the permission name and the value determines whether to grant or revoke that permission. Any value that evaluates to TRUE will cause the permission to be granted. Any value that evaluates to FALSE will cause the permission to be revoked.
[
'administer group' => 0,
// Revoke 'administer group'
'edit group' => FALSE,
// Revoke 'edit group'
'administer members' => 1,
// Grant 'administer members'
'leave group' => TRUE,
// Grant 'leave group'
'join group' => 'join group',
];
Existing permissions are not changed, unless specified in $permissions.
Return value
\Drupal\group\Entity\GroupRoleInterface The group role this was called on.
1 method overrides GroupRoleInterface::changePermissions()
- GroupRole::changePermissions in src/
Entity/ GroupRole.php - Changes permissions for the role.
File
- src/
Entity/ GroupRoleInterface.php, line 186
Class
- GroupRoleInterface
- Provides an interface defining a group role entity.
Namespace
Drupal\group\EntityCode
public function changePermissions(array $permissions = []);