You are here

public function GroupMembershipPermissionProvider::buildPermissions in Group 8

Provides a list of group permissions the plugin exposes.

If you have some group permissions that would only make sense when your plugin is installed, you may define those here. They will not be shown on the permission configuration form unless the plugin is installed.

Return value

array An array of group permissions, see GroupPermissionHandlerInterface for the structure of a group permission.

Overrides GroupContentPermissionProvider::buildPermissions

See also

GroupPermissionHandlerInterface::getPermissions()

File

src/Plugin/GroupMembershipPermissionProvider.php, line 43

Class

GroupMembershipPermissionProvider
Provides group permissions for group_membership GroupContent entities.

Namespace

Drupal\group\Plugin

Code

public function buildPermissions() {
  $permissions = parent::buildPermissions();
  $permissions['join group'] = [
    'title' => 'Join group',
    'allowed for' => [
      'outsider',
    ],
  ];

  // Update the labels of the default permissions.
  $permissions[$this
    ->getAdminPermission()]['title'] = 'Administer group members';
  $permissions[$this
    ->getRelationViewPermission()]['title'] = 'View individual group members';
  $permissions[$this
    ->getRelationUpdatePermission('own')]['title'] = 'Edit own membership';
  $permissions[$this
    ->getRelationDeletePermission('own')]['title'] = 'Leave group';

  // Update the audience of the default permissions.
  $permissions[$this
    ->getRelationUpdatePermission('own')]['allowed for'] = [
    'member',
  ];
  $permissions[$this
    ->getRelationDeletePermission('own')]['allowed for'] = [
    'member',
  ];
  return $permissions;
}