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
- class \Drupal\og\Permission implements PermissionInterface
- class \Drupal\og\GroupContentOperationPermission
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\ogView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
GroupContentOperationPermission:: |
protected | property | The group content bundle ID to which this permission applies. | |
GroupContentOperationPermission:: |
protected | property | The group content entity type ID to which this permission applies. | |
GroupContentOperationPermission:: |
protected | property | The entity operation to which this permission applies. | |
GroupContentOperationPermission:: |
protected | property | If this applies to all entities, or only to the ones owned by the user. | |
GroupContentOperationPermission:: |
public | function | Returns the group content bundle ID to which this permission applies. | |
GroupContentOperationPermission:: |
public | function | Returns the group content entity type ID to which this permission applies. | |
GroupContentOperationPermission:: |
public | function | Returns the operation to which this permission applies. | |
GroupContentOperationPermission:: |
public | function | Returns the owner scope of this permission. | |
GroupContentOperationPermission:: |
public | function | Sets the group content bundle ID to which this permission applies. | |
GroupContentOperationPermission:: |
public | function | Sets the group content entity type ID to which this permission applies. | |
GroupContentOperationPermission:: |
public | function | Sets the operation to which this permission applies. | |
GroupContentOperationPermission:: |
public | function | Sets the owner scope of this permission. | |
GroupContentOperationPermission:: |
protected | function |
Validates the given property and value. Overrides Permission:: |
|
Permission:: |
protected | property | The default roles to which this permission applies. | |
Permission:: |
protected | property | A short description of the permission. | |
Permission:: |
protected | property | The name of the permission. | |
Permission:: |
protected | property | If the permission is security sensitive and should be limited to admins. | |
Permission:: |
protected | property | The human readable permission title. | |
Permission:: |
public | function |
Returns the value for the given property. Overrides PermissionInterface:: |
|
Permission:: |
public | function |
Returns the default roles. Overrides PermissionInterface:: |
|
Permission:: |
public | function |
Returns the description. Overrides PermissionInterface:: |
|
Permission:: |
public | function |
Returns the machine name of the permission. Overrides PermissionInterface:: |
|
Permission:: |
public | function |
Returns whether or not access is restricted. Overrides PermissionInterface:: |
|
Permission:: |
public | function |
Returns the human readable permission title. Overrides PermissionInterface:: |
|
Permission:: |
protected static | function | Converts the given string in a lowerCamelCase version. | |
Permission:: |
public | function |
Sets the value for the given property. Overrides PermissionInterface:: |
|
Permission:: |
public | function |
Sets the default roles. Overrides PermissionInterface:: |
|
Permission:: |
public | function |
Sets the description. Overrides PermissionInterface:: |
|
Permission:: |
public | function |
Sets the machine name of the permission. Overrides PermissionInterface:: |
|
Permission:: |
public | function |
Sets the access restriction. Overrides PermissionInterface:: |
|
Permission:: |
public | function |
Sets the human readable permission title. Overrides PermissionInterface:: |
|
Permission:: |
public | function | Constructs a Permission object. |