Skip to content

Commit

Permalink
Move cache contexts around, given permission rules.
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-vessey committed Jun 25, 2024
1 parent ab79f89 commit 7c3d00d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Access/EmbargoAccessCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, Req
*/
public function access(EntityInterface $entity, AccountInterface $user) {
$type = $this->entityTypeManager->getDefinition('embargo');
$state = AccessResult::neutral()
->addCacheTags($type->getListCacheTags())
->addCacheContexts($type->getListCacheContexts());
$state = AccessResult::neutral();

if ($user->hasPermission('bypass embargo access')) {
return $state->setReason('User has embargo bypass permission.')
Expand All @@ -69,6 +67,8 @@ public function access(EntityInterface $entity, AccountInterface $user) {

/** @var \Drupal\embargo\EmbargoStorage $storage */
$storage = $this->entityTypeManager->getStorage('embargo');
$state->addCacheTags($type->getListCacheTags())
->addCacheContexts($type->getListCacheContexts());
$related_embargoes = $storage->getApplicableEmbargoes($entity);
if (empty($related_embargoes)) {
return $state->setReason('No embargo statements for the given entity.');
Expand Down

0 comments on commit 7c3d00d

Please sign in to comment.