You are here

protected function OgEventSubscriber::getDefaultEntityOperationPermissions in Organic groups 8

Returns a list of generic entity operation permissions for group content.

This returns generic group content entity operation permissions for the operations 'create', 'update' and 'delete'.

In Drupal the entity operation permissions are not following a machine writable naming scheme, but instead they use an arbitrary human readable format. For example the permission to update nodes of type article is 'edit own article content'. This does not even contain the operation 'update' or the entity type 'node'.

OG needs to be able to provide basic CRUD permissions for its group content even if it cannot generate the proper human readable versions. This method settles for a generic permission format '{operation} {ownership} {bundle} {entity type}'. For example for editing articles this would become 'update own article node'.

Modules can implement their own PermissionEvent to declare their proper permissions to use instead of the generic ones. For an example implementation, see `provideDefaultNodePermissions()`.

Parameters

array $group_content_bundle_ids: An array of group content bundle IDs, keyed by group content entity type ID.

Return value

\Drupal\og\GroupContentOperationPermission[] The array of permissions.

See also

\Drupal\og\EventSubscriber\OgEventSubscriber::provideDefaultNodePermissions()

1 call to OgEventSubscriber::getDefaultEntityOperationPermissions()
OgEventSubscriber::provideDefaultOgPermissions in src/EventSubscriber/OgEventSubscriber.php
Provides default OG permissions.

File

src/EventSubscriber/OgEventSubscriber.php, line 278

Class

OgEventSubscriber
Event subscribers for Organic Groups.

Namespace

Drupal\og\EventSubscriber

Code

protected function getDefaultEntityOperationPermissions(array $group_content_bundle_ids) {
  $permissions = [];
  foreach ($group_content_bundle_ids as $group_content_entity_type_id => $bundle_ids) {
    foreach ($bundle_ids as $bundle_id) {
      $permissions += $this
        ->generateEntityOperationPermissionList($group_content_entity_type_id, $bundle_id);
    }
  }
  return $permissions;
}