public function PermissionManager::getDefaultEntityOperationPermissions in Organic groups 8
Returns the list of entity operation permissions for a given group content.
This returns group content entity operation permissions such as 'edit own article content'.
New default group content entity operation permissions can be added by creating an event listener for the PermissionEvent. The default group content operation permissions that ship with Organic Groups can be found in OgEventSubscriber.
Parameters
string $group_entity_type_id: The entity type ID of the group for which to return permissions.
string $group_bundle_id: The bundle ID of the group for which to return permissions.
array $group_content_bundle_ids: An array of group content bundle IDs, keyed by group content entity type ID.
string|null $role_name: Optional default role name to filter the permissions on. If omitted, all permissions will be returned.
Return value
\Drupal\og\GroupContentOperationPermission[] The array of permissions.
Overrides PermissionManagerInterface::getDefaultEntityOperationPermissions
See also
\Drupal\og\Event\PermissionEventInterface
\Drupal\og\EventSubscriber\OgEventSubscriber::provideDefaultNodePermissions()
\Drupal\og\EventSubscriber\OgEventSubscriber::getDefaultEntityOperationPermissions()
File
- src/
PermissionManager.php, line 65
Class
- PermissionManager
- Manager for OG permissions.
Namespace
Drupal\ogCode
public function getDefaultEntityOperationPermissions($group_entity_type_id, $group_bundle_id, array $group_content_bundle_ids, $role_name = NULL) {
$permissions = $this
->getDefaultPermissions($group_entity_type_id, $group_bundle_id, $group_content_bundle_ids, $role_name);
$permissions = array_filter($permissions, function (PermissionInterface $permission) use ($role_name) {
// Only keep entity operation permissions.
if (!$permission instanceof GroupContentOperationPermission) {
return FALSE;
}
// Optionally filter on role name.
$default_roles = $permission
->getDefaultRoles();
return empty($role_name) || !empty($default_roles) && in_array($role_name, $permission
->getDefaultRoles());
});
return $permissions;
}