You are here

class GroupMembershipPermissionProvider in Group 8

Provides group permissions for group_membership GroupContent entities.

Hierarchy

Expanded class hierarchy of GroupMembershipPermissionProvider

File

src/Plugin/GroupMembershipPermissionProvider.php, line 8

Namespace

Drupal\group\Plugin
View source
class GroupMembershipPermissionProvider extends GroupContentPermissionProvider {

  /**
   * {@inheritdoc}
   */
  public function getRelationUpdatePermission($scope = 'any') {

    // Update any is handled by the admin permission.
    if ($scope === 'own') {
      return parent::getRelationUpdatePermission($scope);
    }
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function getRelationDeletePermission($scope = 'any') {

    // Delete any is handled by the admin permission.
    if ($scope === 'own') {
      return 'leave group';
    }
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function getRelationCreatePermission() {

    // Create is handled by the admin permission.
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function buildPermissions() {
    $permissions = parent::buildPermissions();
    $permissions['join group'] = [
      'title' => 'Join group',
      'allowed for' => [
        'outsider',
      ],
    ];

    // Update the labels of the default permissions.
    $permissions[$this
      ->getAdminPermission()]['title'] = 'Administer group members';
    $permissions[$this
      ->getRelationViewPermission()]['title'] = 'View individual group members';
    $permissions[$this
      ->getRelationUpdatePermission('own')]['title'] = 'Edit own membership';
    $permissions[$this
      ->getRelationDeletePermission('own')]['title'] = 'Leave group';

    // Update the audience of the default permissions.
    $permissions[$this
      ->getRelationUpdatePermission('own')]['allowed for'] = [
      'member',
    ];
    $permissions[$this
      ->getRelationDeletePermission('own')]['allowed for'] = [
      'member',
    ];
    return $permissions;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
GroupContentHandlerBase::$definition protected property The group content enabler definition.
GroupContentHandlerBase::$moduleHandler protected property The module handler to invoke hooks on.
GroupContentHandlerBase::$pluginId protected property The plugin ID as read from the definition.
GroupContentHandlerBase::moduleHandler protected function Gets the module handler.
GroupContentHandlerBase::setModuleHandler public function Sets the module handler for this handler.
GroupContentHandlerBase::__construct public function Constructs a GroupContentHandlerBase object.
GroupContentPermissionProvider::$definesEntityPermissions protected property Whether the plugin defines permissions for the target entity type.
GroupContentPermissionProvider::$entityType protected property The entity type the enabler is for.
GroupContentPermissionProvider::$implementsOwnerInterface protected property Whether the target entity type implements the EntityOwnerInterface.
GroupContentPermissionProvider::$implementsPublishedInterface protected property Whether the target entity type implements the EntityPublishedInterface.
GroupContentPermissionProvider::buildPermission protected function Builds a permission with common translation arguments predefined.
GroupContentPermissionProvider::createInstance public static function Instantiates a new instance of this group content handler. Overrides GroupContentHandlerBase::createInstance
GroupContentPermissionProvider::getAdminPermission public function Gets the name of the admin permission. Overrides GroupContentPermissionProviderInterface::getAdminPermission
GroupContentPermissionProvider::getEntityCreatePermission public function Gets the name of the create permission for the relation. Overrides GroupContentPermissionProviderInterface::getEntityCreatePermission
GroupContentPermissionProvider::getEntityDeletePermission public function Gets the name of the delete permission for the relation. Overrides GroupContentPermissionProviderInterface::getEntityDeletePermission
GroupContentPermissionProvider::getEntityUpdatePermission public function Gets the name of the update permission for the relation. Overrides GroupContentPermissionProviderInterface::getEntityUpdatePermission
GroupContentPermissionProvider::getEntityViewPermission public function Gets the name of the view permission for the relation. Overrides GroupContentPermissionProviderInterface::getEntityViewPermission 1
GroupContentPermissionProvider::getEntityViewUnpublishedPermission public function Gets the name of the view unpublished permission for the relation. Overrides GroupContentPermissionProviderInterface::getEntityViewUnpublishedPermission 2
GroupContentPermissionProvider::getPermission public function Gets the name of the permission for the given operation, target and scope. Overrides GroupContentPermissionProviderInterface::getPermission
GroupContentPermissionProvider::getRelationViewPermission public function Gets the name of the view permission for the relation. Overrides GroupContentPermissionProviderInterface::getRelationViewPermission
GroupMembershipPermissionProvider::buildPermissions public function Provides a list of group permissions the plugin exposes. Overrides GroupContentPermissionProvider::buildPermissions
GroupMembershipPermissionProvider::getRelationCreatePermission public function Gets the name of the create permission for the relation. Overrides GroupContentPermissionProvider::getRelationCreatePermission
GroupMembershipPermissionProvider::getRelationDeletePermission public function Gets the name of the delete permission for the relation. Overrides GroupContentPermissionProvider::getRelationDeletePermission
GroupMembershipPermissionProvider::getRelationUpdatePermission public function Gets the name of the update permission for the relation. Overrides GroupContentPermissionProvider::getRelationUpdatePermission