You are here

public function RngEntityAccess::hook_entity_access in RNG - Events and Registrations 3.x

Same name and namespace in other branches
  1. 8.2 src/RngEntityAccess.php \Drupal\rng\RngEntityAccess::hook_entity_access()
  2. 8 src/RngEntityAccess.php \Drupal\rng\RngEntityAccess::hook_entity_access()

Control entity operation access.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to check access to.

string $operation: The operation that is to be performed on $entity.

\Drupal\Core\Session\AccountInterface $account: The account trying to access the entity.

Return value

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

See also

hook_entity_access();

File

src/RngEntityAccess.php, line 49

Class

RngEntityAccess
RNG entity access.

Namespace

Drupal\rng

Code

public function hook_entity_access(EntityInterface $entity, $operation, AccountInterface $account) {
  if ('manage event' == $operation && $this->eventManager
    ->isEvent($entity)) {
    return $this
      ->manageEventAccess($entity, $account);
  }
  if ('update' == $operation && $entity instanceof ChannelInterface) {
    return $this
      ->updateCourierMessageAccess($entity, $account);
  }
  if ('templates' == $operation && $entity instanceof TemplateCollectionInterface) {
    return $this
      ->templateCollectionTemplateAccess($entity, $account);
  }
  return AccessResult::neutral();
}