You are here

class GroupContentOperationPermission in Organic groups 8

A group level permission.

This is used for permissions to perform operations on group content, for example 'edit own article content'.

Hierarchy

Expanded class hierarchy of GroupContentOperationPermission

5 files declare their use of GroupContentOperationPermission
GroupContentOperationPermissionTest.php in tests/src/Unit/GroupContentOperationPermissionTest.php
OgEventSubscriber.php in src/EventSubscriber/OgEventSubscriber.php
PermissionEvent.php in src/Event/PermissionEvent.php
PermissionEventTest.php in tests/src/Unit/PermissionEventTest.php
PermissionEventTest.php in tests/src/Kernel/PermissionEventTest.php

File

src/GroupContentOperationPermission.php, line 13

Namespace

Drupal\og
View source
class GroupContentOperationPermission extends Permission {

  /**
   * The group content entity type ID to which this permission applies.
   *
   * @var string
   */
  protected $entityType;

  /**
   * The group content bundle ID to which this permission applies.
   *
   * @var string
   */
  protected $bundle;

  /**
   * The entity operation to which this permission applies.
   *
   * Examples: 'create', 'update', 'delete'.
   *
   * @var string
   */
  protected $operation;

  /**
   * If this applies to all entities, or only to the ones owned by the user.
   *
   * Use this to make the distinction between 'edit any article content' and
   * 'edit own article content'.
   *
   * @var bool
   *   FALSE if this permission applies to all entities, TRUE if it only applies
   *   to the entities owned by the user.
   */
  protected $owner = FALSE;

  /**
   * Returns the group content entity type ID to which this permission applies.
   *
   * @return string
   *   The group content entity type ID.
   */
  public function getEntityType() {
    return $this
      ->get('entity type');
  }

  /**
   * Sets the group content entity type ID to which this permission applies.
   *
   * @param string $entity_type
   *   The group content entity type ID.
   *
   * @return $this
   */
  public function setEntityType($entity_type) {
    $this
      ->set('entity type', $entity_type);
    return $this;
  }

  /**
   * Returns the group content bundle ID to which this permission applies.
   *
   * @return string
   *   The group content bundle ID.
   */
  public function getBundle() {
    return $this
      ->get('bundle');
  }

  /**
   * Sets the group content bundle ID to which this permission applies.
   *
   * @param string $bundle
   *   The group content bundle ID.
   *
   * @return $this
   */
  public function setBundle($bundle) {
    $this
      ->set('bundle', $bundle);
    return $this;
  }

  /**
   * Returns the operation to which this permission applies.
   *
   * @return string
   *   The operation.
   */
  public function getOperation() {
    return $this
      ->get('operation');
  }

  /**
   * Sets the operation to which this permission applies.
   *
   * @param string $operation
   *   The operation. For example 'create', 'update', or 'delete'.
   *
   * @return $this
   */
  public function setOperation($operation) {
    $this
      ->set('operation', $operation);
    return $this;
  }

  /**
   * Returns the owner scope of this permission.
   *
   * @return bool
   *   FALSE if this permission applies to all entities, TRUE if it only applies
   *   to the entities owned by the user.
   */
  public function getOwner() {
    return $this
      ->get('owner');
  }

  /**
   * Sets the owner scope of this permission.
   *
   * @param bool $owner
   *   FALSE if this permission applies to all entities, TRUE if it only applies
   *   to the entities owned by the user.
   *
   * @return $this
   */
  public function setOwner($owner) {
    $this
      ->set('owner', $owner);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  protected function validate($property, $value) {
    parent::validate($property, $value);
    if ($property === 'owner' && !is_bool($value)) {
      throw new \InvalidArgumentException('The owner should be a boolean value.');
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
GroupContentOperationPermission::$bundle protected property The group content bundle ID to which this permission applies.
GroupContentOperationPermission::$entityType protected property The group content entity type ID to which this permission applies.
GroupContentOperationPermission::$operation protected property The entity operation to which this permission applies.
GroupContentOperationPermission::$owner protected property If this applies to all entities, or only to the ones owned by the user.
GroupContentOperationPermission::getBundle public function Returns the group content bundle ID to which this permission applies.
GroupContentOperationPermission::getEntityType public function Returns the group content entity type ID to which this permission applies.
GroupContentOperationPermission::getOperation public function Returns the operation to which this permission applies.
GroupContentOperationPermission::getOwner public function Returns the owner scope of this permission.
GroupContentOperationPermission::setBundle public function Sets the group content bundle ID to which this permission applies.
GroupContentOperationPermission::setEntityType public function Sets the group content entity type ID to which this permission applies.
GroupContentOperationPermission::setOperation public function Sets the operation to which this permission applies.
GroupContentOperationPermission::setOwner public function Sets the owner scope of this permission.
GroupContentOperationPermission::validate protected function Validates the given property and value. Overrides Permission::validate
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::__construct public function Constructs a Permission object.