Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Commit

Permalink
Add a new group level permission that allows to delete the group.
Browse files Browse the repository at this point in the history
  • Loading branch information
pfrenssen committed Jul 31, 2020
1 parent db1354d commit 05633f9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/EventSubscriber/OgEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ public function provideDefaultOgPermissions(PermissionEventInterface $event) {
'description' => $this->t('Edit the group entity.'),
'default roles' => [OgRoleInterface::ADMINISTRATOR],
]),
new GroupPermission([
'name' => OgAccess::DELETE_GROUP_PERMISSION,
'title' => $this->t('Delete group'),
'description' => $this->t('Delete the group.'),
'default roles' => [OgRoleInterface::ADMINISTRATOR],
]),
new GroupPermission([
'name' => OgAccess::ADMINISTER_GROUP_PERMISSION,
'title' => $this->t('Administer group'),
Expand Down
6 changes: 6 additions & 0 deletions src/OgAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class OgAccess implements OgAccessInterface {
*/
const ADMINISTER_GROUP_PERMISSION = 'administer group';

/**
* Group level permission that allows the user to delete the group entity.
*/
const DELETE_GROUP_PERMISSION = 'delete group';

/**
* Group level permission that allows the user to update the group entity.
*/
Expand All @@ -38,6 +43,7 @@ class OgAccess implements OgAccessInterface {
* Maps entity operations performed on groups to group level permissions.
*/
const OPERATION_GROUP_PERMISSION_MAPPING = [
'delete' => self::DELETE_GROUP_PERMISSION,
'update' => self::UPDATE_GROUP_PERMISSION,
];

Expand Down

0 comments on commit 05633f9

Please sign in to comment.