From ab79f893f7a3bcf8be4ca7faccf60bb0047e5930 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Mon, 24 Jun 2024 11:30:05 -0300 Subject: [PATCH] Account for bypass on individual entities. --- src/Access/EmbargoAccessCheck.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Access/EmbargoAccessCheck.php b/src/Access/EmbargoAccessCheck.php index 9af1cfe..186d4fb 100644 --- a/src/Access/EmbargoAccessCheck.php +++ b/src/Access/EmbargoAccessCheck.php @@ -62,6 +62,11 @@ public function access(EntityInterface $entity, AccountInterface $user) { ->addCacheTags($type->getListCacheTags()) ->addCacheContexts($type->getListCacheContexts()); + if ($user->hasPermission('bypass embargo access')) { + return $state->setReason('User has embargo bypass permission.') + ->addCacheContexts(['user.permissions']); + } + /** @var \Drupal\embargo\EmbargoStorage $storage */ $storage = $this->entityTypeManager->getStorage('embargo'); $related_embargoes = $storage->getApplicableEmbargoes($entity);