You are here

public function GroupMembershipPermissionProvider::getPermission in Group 2.0.x

Gets the name of the permission for the given operation, target and scope.

Parameters

string $operation: The permission operation. Usually "create", "view", "update" or "delete".

string $target: The target of the operation. Can be 'relation' or 'entity'.

string $scope: (optional) Whether the 'any' or 'own' permission name should be returned. Defaults to 'any'.

Return value

string|false The permission name or FALSE if it does not apply.

Overrides PermissionProviderTrait::getPermission

File

src/Plugin/Group/RelationHandler/GroupMembershipPermissionProvider.php, line 25

Class

GroupMembershipPermissionProvider
Provides group permissions for the group_membership relation plugin.

Namespace

Drupal\group\Plugin\Group\RelationHandler

Code

public function getPermission($operation, $target, $scope = 'any') {

  // The following permissions are handled by the admin permission or have a
  // different permission name.
  if ($target === 'relation') {
    switch ($operation) {
      case 'create':
        return FALSE;
      case 'delete':
        return $scope === 'own' ? 'leave group' : FALSE;
      case 'update':
        if ($scope === 'any') {
          return FALSE;
        }
        break;
    }
  }
  return $this->parent
    ->getPermission($operation, $target, $scope);
}