You are here

protected function RngEntityAccess::manageEventAccess in RNG - Events and Registrations 3.x

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

Whether the account is permitted to manage event.

This method is a proxy for a different permission name.

Parameters

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

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

Return value

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

1 call to RngEntityAccess::manageEventAccess()
RngEntityAccess::hook_entity_access in src/RngEntityAccess.php
Control entity operation access.

File

src/RngEntityAccess.php, line 78

Class

RngEntityAccess
RNG entity access.

Namespace

Drupal\rng

Code

protected function manageEventAccess($entity, AccountInterface $account) {
  $event_type = $this->eventManager
    ->eventType($entity
    ->getEntityTypeId(), $entity
    ->bundle());
  $manage_operation = $event_type
    ->getEventManageOperation();

  // Prevents recursion:
  if (!empty($manage_operation) && 'manage event' != $manage_operation) {
    if ($entity
      ->access($manage_operation, $account)) {
      return AccessResult::allowed()
        ->addCacheableDependency($entity);
    }
  }
  return AccessResult::neutral();
}