class PermissionManager in Organic groups 8
Manager for OG permissions.
Hierarchy
- class \Drupal\og\PermissionManager implements PermissionManagerInterface
Expanded class hierarchy of PermissionManager
1 file declares its use of PermissionManager
- OgAccessTestBase.php in tests/
src/ Unit/ OgAccessTestBase.php
1 string reference to 'PermissionManager'
1 service uses PermissionManager
File
- src/
PermissionManager.php, line 14
Namespace
Drupal\ogView source
class PermissionManager implements PermissionManagerInterface {
/**
* The event dispatcher.
*
* @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
*/
protected $eventDispatcher;
/**
* Constructs a PermissionManager object.
*
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
* The event dispatcher.
*/
public function __construct(EventDispatcherInterface $event_dispatcher) {
$this->eventDispatcher = $event_dispatcher;
}
/**
* {@inheritdoc}
*/
public function getDefaultPermissions($group_entity_type_id, $group_bundle_id, array $group_content_bundle_ids, $role_name = NULL) {
$event = new PermissionEvent($group_entity_type_id, $group_bundle_id, $group_content_bundle_ids);
$this->eventDispatcher
->dispatch(PermissionEventInterface::EVENT_NAME, $event);
return $event
->getPermissions();
}
/**
* {@inheritdoc}
*/
public function getDefaultGroupPermissions($group_entity_type_id, $group_bundle_id, $role_name = NULL) {
$permissions = $this
->getDefaultPermissions($group_entity_type_id, $group_bundle_id, [], $role_name);
$permissions = array_filter($permissions, function (PermissionInterface $permission) use ($role_name) {
// Only keep group permissions.
if (!$permission instanceof GroupPermission) {
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;
}
/**
* {@inheritdoc}
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PermissionManager:: |
protected | property | The event dispatcher. | |
PermissionManager:: |
public | function |
Returns the list of entity operation permissions for a given group content. Overrides PermissionManagerInterface:: |
|
PermissionManager:: |
public | function |
Returns permissions that are enabled by default for the given role. Overrides PermissionManagerInterface:: |
|
PermissionManager:: |
public | function |
Returns the full set of default permissions for a group and its content. Overrides PermissionManagerInterface:: |
|
PermissionManager:: |
public | function | Constructs a PermissionManager object. |