You are here

class GroupPermission in Organic groups 8

A group level permission.

This is used for permissions that apply to the group as a whole, such as 'subscribe without approval' and 'administer group'.

Hierarchy

Expanded class hierarchy of GroupPermission

4 files declare their use of GroupPermission
GroupPermissionTest.php in tests/src/Unit/GroupPermissionTest.php
OgEventSubscriber.php in src/EventSubscriber/OgEventSubscriber.php
PermissionEventTest.php in tests/src/Unit/PermissionEventTest.php
PermissionEventTest.php in tests/src/Kernel/PermissionEventTest.php

File

src/GroupPermission.php, line 13

Namespace

Drupal\og
View source
class GroupPermission extends Permission {

  /**
   * A list of roles to which this permission can be applied.
   *
   * For example, the 'subscribe' permission only applies to non-members. If
   * left empty, this permission applies to all roles.
   *
   * @var array
   */
  protected $roles = [];

  /**
   * Returns the roles to which this permission can be applied.
   *
   * For example, the 'subscribe' permission only applies to non-members.
   *
   * @return array
   *   An array of roles to which this permission applies. If empty, the
   *   permission applies to all roles.
   */
  public function getApplicableRoles() {
    return $this
      ->get('roles');
  }

  /**
   * Returns the roles to which this permission can be applied.
   *
   * For example, the 'subscribe' permission only applies to non-members.
   *
   * @param array $roles
   *   An array of roles to which this permission applies. If empty, the
   *   permission applies to all roles.
   *
   * @return $this
   */
  public function setApplicableRoles(array $roles) {
    $this
      ->set('roles', $roles);
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
GroupPermission::$roles protected property A list of roles to which this permission can be applied.
GroupPermission::getApplicableRoles public function Returns the roles to which this permission can be applied.
GroupPermission::setApplicableRoles public function Returns the roles to which this permission can be applied.
Permission::$defaultRoles protected property The default roles to which this permission applies.
Permission::$description protected property A short description of the permission.
Permission::$name protected property The name of the permission.
Permission::$restrictAccess protected property If the permission is security sensitive and should be limited to admins.
Permission::$title protected property The human readable permission title.
Permission::get public function Returns the value for the given property. Overrides PermissionInterface::get
Permission::getDefaultRoles public function Returns the default roles. Overrides PermissionInterface::getDefaultRoles
Permission::getDescription public function Returns the description. Overrides PermissionInterface::getDescription
Permission::getName public function Returns the machine name of the permission. Overrides PermissionInterface::getName
Permission::getRestrictAccess public function Returns whether or not access is restricted. Overrides PermissionInterface::getRestrictAccess
Permission::getTitle public function Returns the human readable permission title. Overrides PermissionInterface::getTitle
Permission::lowerCamelize protected static function Converts the given string in a lowerCamelCase version.
Permission::set public function Sets the value for the given property. Overrides PermissionInterface::set
Permission::setDefaultRoles public function Sets the default roles. Overrides PermissionInterface::setDefaultRoles
Permission::setDescription public function Sets the description. Overrides PermissionInterface::setDescription
Permission::setName public function Sets the machine name of the permission. Overrides PermissionInterface::setName
Permission::setRestrictAccess public function Sets the access restriction. Overrides PermissionInterface::setRestrictAccess
Permission::setTitle public function Sets the human readable permission title. Overrides PermissionInterface::setTitle
Permission::validate protected function Validates the given property and value. 1
Permission::__construct public function Constructs a Permission object.