You are here

class GroupNodePermissionProvider in Group 2.0.x

Provides group permissions for the group_node relation plugin.

Hierarchy

Expanded class hierarchy of GroupNodePermissionProvider

File

modules/gnode/src/Plugin/Group/RelationHandler/GroupNodePermissionProvider.php, line 12

Namespace

Drupal\gnode\Plugin\Group\RelationHandler
View source
class GroupNodePermissionProvider implements PermissionProviderInterface {
  use PermissionProviderTrait;

  /**
   * Constructs a new GroupMembershipPermissionProvider.
   *
   * @param \Drupal\group\Plugin\Group\RelationHandler\PermissionProviderInterface $parent
   *   The parent permission provider.
   */
  public function __construct(PermissionProviderInterface $parent) {
    $this->parent = $parent;
  }

  /**
   * {@inheritdoc}
   */
  public function getPermission($operation, $target, $scope = 'any') {

    // Backwards compatible permission name for 'any' scope.
    if ($operation === 'view unpublished' && $target === 'entity' && $scope === 'any') {
      return "{$operation} {$this->pluginId} {$target}";
    }
    return $this->parent
      ->getPermission($operation, $target, $scope);
  }

  /**
   * {@inheritdoc}
   */
  public function buildPermissions() {
    $permissions = $this->parent
      ->buildPermissions();

    // Rename the view any unpublished entity permission.
    if ($name = $this->parent
      ->getPermission('view', 'entity', 'any')) {
      $permissions[$this
        ->getPermission('view', 'entity', 'any')] = $permissions[$name];
      unset($permissions[$name]);
    }
    return $permissions;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
GroupNodePermissionProvider::buildPermissions public function Provides a list of group permissions the plugin exposes. Overrides PermissionProviderTrait::buildPermissions
GroupNodePermissionProvider::getPermission public function Gets the name of the permission for the given operation, target and scope. Overrides PermissionProviderTrait::getPermission
GroupNodePermissionProvider::__construct public function Constructs a new GroupMembershipPermissionProvider.
PermissionProviderTrait::$definesEntityPermissions protected property Whether the plugin defines permissions for the target entity type.
PermissionProviderTrait::$entityType protected property The entity type the plugin handler is for.
PermissionProviderTrait::$implementsOwnerInterface protected property Whether the target entity type implements the EntityOwnerInterface.
PermissionProviderTrait::$implementsPublishedInterface protected property Whether the target entity type implements the EntityPublishedInterface.
PermissionProviderTrait::buildPermission protected function Builds a permission with common translation arguments predefined.
PermissionProviderTrait::getAdminPermission public function 4
PermissionProviderTrait::init public function
RelationHandlerTrait::$definition protected property The plugin definition.
RelationHandlerTrait::$entityTypeManager protected property The entity type manager.
RelationHandlerTrait::$groupRelationManager protected property The group relation manager.
RelationHandlerTrait::$parent protected property The parent relation handler in the decorator chain.
RelationHandlerTrait::$pluginId protected property The plugin ID as read from the definition.
RelationHandlerTrait::entityTypeManager protected function Gets the entity type manager service.
RelationHandlerTrait::groupRelationManager protected function Gets the group relation manager service.
RelationHandlerTrait::init public function Aliased as: traitInit