You are here

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

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

Allow editing template if the user has 'manage event' for the event.

Parameters

\Drupal\courier\ChannelInterface $entity: A Courier template entity.

\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::updateCourierMessageAccess()
RngEntityAccess::hook_entity_access in src/RngEntityAccess.php
Control entity operation access.

File

src/RngEntityAccess.php, line 105

Class

RngEntityAccess
RNG entity access.

Namespace

Drupal\rng

Code

protected function updateCourierMessageAccess(ChannelInterface $entity, AccountInterface $account) {
  $template_collection = TemplateCollection::getTemplateCollectionForTemplate($entity);
  if ($template_collection) {
    $owner = $template_collection
      ->getOwner();
    if ($owner && $this->eventManager
      ->isEvent($owner)) {
      return AccessResult::allowedIf($owner
        ->access('manage event', $account))
        ->addCacheableDependency($owner);
    }
  }
  return AccessResult::neutral();
}