You are here

public function GroupContentPermissionProvider::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 GroupContentPermissionProviderInterface::buildPermissions

See also

GroupPermissionHandlerInterface::getPermissions()

1 call to GroupContentPermissionProvider::buildPermissions()
GroupMembershipPermissionProvider::buildPermissions in src/Plugin/GroupMembershipPermissionProvider.php
Provides a list of group permissions the plugin exposes.
1 method overrides GroupContentPermissionProvider::buildPermissions()
GroupMembershipPermissionProvider::buildPermissions in src/Plugin/GroupMembershipPermissionProvider.php
Provides a list of group permissions the plugin exposes.

File

src/Plugin/GroupContentPermissionProvider.php, line 204

Class

GroupContentPermissionProvider
Provides group permissions for GroupContent entities.

Namespace

Drupal\group\Plugin

Code

public function buildPermissions() {
  $permissions = [];

  // Provide permissions for the relation (i.e.: The group content entity).
  $prefix = 'Relation:';
  if ($name = $this
    ->getAdminPermission()) {
    $permissions[$name] = $this
      ->buildPermission("{$prefix} Administer relations");
    $permissions[$name]['restrict access'] = TRUE;
  }
  if ($name = $this
    ->getRelationViewPermission()) {
    $permissions[$name] = $this
      ->buildPermission("{$prefix} View any entity relations");
  }
  if ($name = $this
    ->getRelationViewPermission('own')) {
    $permissions[$name] = $this
      ->buildPermission("{$prefix} View own entity relations");
  }
  if ($name = $this
    ->getRelationUpdatePermission()) {
    $permissions[$name] = $this
      ->buildPermission("{$prefix} Edit any entity relations");
  }
  if ($name = $this
    ->getRelationUpdatePermission('own')) {
    $permissions[$name] = $this
      ->buildPermission("{$prefix} Edit own entity relations");
  }
  if ($name = $this
    ->getRelationDeletePermission()) {
    $permissions[$name] = $this
      ->buildPermission("{$prefix} Delete any entity relations");
  }
  if ($name = $this
    ->getRelationDeletePermission('own')) {
    $permissions[$name] = $this
      ->buildPermission("{$prefix} Delete own entity relations");
  }
  if ($name = $this
    ->getRelationCreatePermission()) {
    $permissions[$name] = $this
      ->buildPermission("{$prefix} Add entity relations", 'Allows you to add an existing %entity_type entity to the group.');
  }

  // Provide permissions for the actual entity being added to the group.
  $prefix = 'Entity:';
  if ($name = $this
    ->getEntityViewPermission()) {
    $permissions[$name] = $this
      ->buildPermission("{$prefix} View any %entity_type entities");
  }
  if ($name = $this
    ->getEntityViewPermission('own')) {
    $permissions[$name] = $this
      ->buildPermission("{$prefix} View own %entity_type entities");
  }
  if ($name = $this
    ->getEntityViewUnpublishedPermission()) {
    $permissions[$name] = $this
      ->buildPermission("{$prefix} View any unpublished %entity_type entities");
  }
  if ($name = $this
    ->getEntityViewUnpublishedPermission('own')) {
    $permissions[$name] = $this
      ->buildPermission("{$prefix} View own unpublished %entity_type entities");
  }
  if ($name = $this
    ->getEntityUpdatePermission()) {
    $permissions[$name] = $this
      ->buildPermission("{$prefix} Edit any %entity_type entities");
  }
  if ($name = $this
    ->getEntityUpdatePermission('own')) {
    $permissions[$name] = $this
      ->buildPermission("{$prefix} Edit own %entity_type entities");
  }
  if ($name = $this
    ->getEntityDeletePermission()) {
    $permissions[$name] = $this
      ->buildPermission("{$prefix} Delete any %entity_type entities");
  }
  if ($name = $this
    ->getEntityDeletePermission('own')) {
    $permissions[$name] = $this
      ->buildPermission("{$prefix} Delete own %entity_type entities");
  }
  if ($name = $this
    ->getEntityCreatePermission()) {
    $permissions[$name] = $this
      ->buildPermission("{$prefix} Add %entity_type entities", 'Allows you to create a new %entity_type entity and add it to the group.');
  }
  return $permissions;
}