class FullEntityPermissionProvider in Group 2.0.x
Provides all possible permissions.
Hierarchy
- class \Drupal\group_test_plugin\Plugin\Group\RelationHandler\FullEntityPermissionProvider implements PermissionProviderInterface uses PermissionProviderTrait
Expanded class hierarchy of FullEntityPermissionProvider
1 string reference to 'FullEntityPermissionProvider'
- group_test_plugin.services.yml in tests/
modules/ group_test_plugin/ group_test_plugin.services.yml - tests/modules/group_test_plugin/group_test_plugin.services.yml
2 services use FullEntityPermissionProvider
- group.relation_handler.permission_provider.entity_test_as_content in tests/
modules/ group_test_plugin/ group_test_plugin.services.yml - Drupal\group_test_plugin\Plugin\Group\RelationHandler\FullEntityPermissionProvider
- group.relation_handler.permission_provider.node_as_content in tests/
modules/ group_test_plugin/ group_test_plugin.services.yml - Drupal\group_test_plugin\Plugin\Group\RelationHandler\FullEntityPermissionProvider
File
- tests/
modules/ group_test_plugin/ src/ Plugin/ Group/ RelationHandler/ FullEntityPermissionProvider.php, line 12
Namespace
Drupal\group_test_plugin\Plugin\Group\RelationHandlerView source
class FullEntityPermissionProvider implements PermissionProviderInterface {
use PermissionProviderTrait;
/**
* Constructs a new FullEntityPermissionProvider.
*
* @param \Drupal\group\Plugin\Group\RelationHandler\PermissionProviderInterface $parent
* The parent permission provider.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(PermissionProviderInterface $parent, EntityTypeManagerInterface $entity_type_manager) {
$this->parent = $parent;
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
public function getPermission($operation, $target, $scope = 'any') {
// The view permissions support all scopes here.
if ($target === 'entity') {
switch ($operation) {
case 'view':
return $this
->getEntityViewPermission($scope);
case 'view unpublished':
return $this
->getEntityViewUnpublishedPermission($scope);
}
}
return $this->parent
->getPermission($operation, $target, $scope);
}
/**
* {@inheritdoc}
*/
public function buildPermissions() {
$permissions = $this->parent
->buildPermissions();
// Rename view any permissions.
if ($name = $this->parent
->getPermission('view', 'entity')) {
$permissions[$this
->getPermission('view', 'entity')] = $permissions[$name];
unset($permissions[$name]);
}
if ($name = $this->parent
->getPermission('view unpublished', 'entity')) {
$permissions[$this
->getPermission('view unpublished', 'entity')] = $permissions[$name];
unset($permissions[$name]);
}
// Support view own permissions.
$prefix = 'Entity:';
if ($name = $this
->getPermission('view', 'entity', 'own')) {
$permissions[$name] = $this
->buildPermission("{$prefix} View own %entity_type entities");
}
if ($name = $this
->getPermission('view unpublished', 'entity', 'own')) {
$permissions[$name] = $this
->buildPermission("{$prefix} View own unpublished %entity_type entities");
}
return $permissions;
}
/**
* Gets the name of the view permission for the entity.
*
* @param string $scope
* (optional) Whether the 'any' or 'own' permission name should be returned.
* Defaults to 'any'.
*
* @return string|false
* The permission name or FALSE if it does not apply.
*/
protected function getEntityViewPermission($scope = 'any') {
if ($this->definesEntityPermissions) {
if ($this->implementsOwnerInterface || $scope === 'any') {
return "view {$scope} {$this->pluginId} entity";
}
}
return FALSE;
}
/**
* Gets the name of the view unpublished permission for the entity.
*
* @param string $scope
* (optional) Whether the 'any' or 'own' permission name should be returned.
* Defaults to 'any'.
*
* @return string|false
* The permission name or FALSE if it does not apply.
*/
protected function getEntityViewUnpublishedPermission($scope = 'any') {
if ($this->definesEntityPermissions) {
if ($this->implementsOwnerInterface || $scope === 'any') {
return "view {$scope} unpublished {$this->pluginId} entity";
}
}
return FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FullEntityPermissionProvider:: |
public | function |
Provides a list of group permissions the plugin exposes. Overrides PermissionProviderTrait:: |
|
FullEntityPermissionProvider:: |
protected | function | Gets the name of the view permission for the entity. | |
FullEntityPermissionProvider:: |
protected | function | Gets the name of the view unpublished permission for the entity. | |
FullEntityPermissionProvider:: |
public | function |
Gets the name of the permission for the given operation, target and scope. Overrides PermissionProviderTrait:: |
|
FullEntityPermissionProvider:: |
public | function | Constructs a new FullEntityPermissionProvider. | |
PermissionProviderTrait:: |
protected | property | Whether the plugin defines permissions for the target entity type. | |
PermissionProviderTrait:: |
protected | property | The entity type the plugin handler is for. | |
PermissionProviderTrait:: |
protected | property | Whether the target entity type implements the EntityOwnerInterface. | |
PermissionProviderTrait:: |
protected | property | Whether the target entity type implements the EntityPublishedInterface. | |
PermissionProviderTrait:: |
protected | function | Builds a permission with common translation arguments predefined. | |
PermissionProviderTrait:: |
public | function | 4 | |
PermissionProviderTrait:: |
public | function | ||
RelationHandlerTrait:: |
protected | property | The plugin definition. | |
RelationHandlerTrait:: |
protected | property | The entity type manager. | |
RelationHandlerTrait:: |
protected | property | The group relation manager. | |
RelationHandlerTrait:: |
protected | property | The parent relation handler in the decorator chain. | |
RelationHandlerTrait:: |
protected | property | The plugin ID as read from the definition. | |
RelationHandlerTrait:: |
protected | function | Gets the entity type manager service. | |
RelationHandlerTrait:: |
protected | function | Gets the group relation manager service. | |
RelationHandlerTrait:: |
public | function | Aliased as: traitInit |