You are here

public function PermissionEvent::getGroupContentOperationPermission in Organic groups 8

Returns a group content operation permission by its identifying properties.

Parameters

string $entity_type_id: The group content entity type ID to which this permission applies.

string $bundle_id: The group content bundle ID to which this permission applies.

string $operation: The entity operation to which this permission applies.

bool $owner: Set to FALSE if this permission applies to all entities, or to TRUE if it only applies to the ones owned by the user. Defaults to FALSE.

Return value

\Drupal\og\GroupContentOperationPermission The permission.

Throws

\InvalidArgumentException Thrown if the permission with the given properties does not exist.

Overrides PermissionEventInterface::getGroupContentOperationPermission

2 calls to PermissionEvent::getGroupContentOperationPermission()
PermissionEvent::deleteGroupContentOperationPermission in src/Event/PermissionEvent.php
Deletes a group content operation permission by its identifying properties.
PermissionEvent::hasGroupContentOperationPermission in src/Event/PermissionEvent.php
Returns if a group content operation permission matches given properties.

File

src/Event/PermissionEvent.php, line 84

Class

PermissionEvent
Event that is fired when OG permissions are compiled.

Namespace

Drupal\og\Event

Code

public function getGroupContentOperationPermission($entity_type_id, $bundle_id, $operation, $owner = FALSE) {
  foreach ($this
    ->getPermissions() as $permission) {
    if ($permission instanceof GroupContentOperationPermission && $permission
      ->getEntityType() === $entity_type_id && $permission
      ->getBundle() === $bundle_id && $permission
      ->getOperation() === $operation && $permission
      ->getOwner() === $owner) {
      return $permission;
    }
  }
  throw new \InvalidArgumentException('The permission with the given properties does not exist.');
}