You are here

public function OgAccessInterface::userAccessGroupContentEntityOperation in Organic groups 8

Checks access for entity operations on group content in a specific group.

This checks if the user has permission to perform the requested operation on the given group content entity according to the user's membership status in the given group. It also passes through ::userAccess() to check for any' of the special cases, such as being the root user, having global permission to administer all groups, etc.

The access result can be altered by implementing an event listener for GroupContentEntityOperationAccessEventInterface::EVENT_NAME.

For access to be granted, at least one of the above checks should grant access, and none of the event listeners should deny access. A neutral result is returned only if all checks are neutral or if the passed in entity is not group content.

Parameters

string $operation: The entity operation, such as "create", "update" or "delete".

\Drupal\Core\Entity\EntityInterface $group_entity: The group entity, to retrieve the permissions from.

\Drupal\Core\Entity\EntityInterface $group_content_entity: The group content entity for which access to the entity operation is requested.

\Drupal\Core\Session\AccountInterface|null $user: Optional user for which to check access. If omitted, the currently logged in user will be used.

Return value

\Drupal\Core\Access\AccessResultInterface The access result object.

1 method overrides OgAccessInterface::userAccessGroupContentEntityOperation()
OgAccess::userAccessGroupContentEntityOperation in src/OgAccess.php
Checks access for entity operations on group content in a specific group.

File

src/OgAccessInterface.php, line 163

Class

OgAccessInterface
Interface for classes that handle access checks in Organic Groups.

Namespace

Drupal\og

Code

public function userAccessGroupContentEntityOperation(string $operation, EntityInterface $group_entity, EntityInterface $group_content_entity, ?AccountInterface $user = NULL) : AccessResultInterface;