diff --git a/src/Access/EmbargoAccessCheck.php b/src/Access/EmbargoAccessCheck.php index e643958..3e6dcf0 100644 --- a/src/Access/EmbargoAccessCheck.php +++ b/src/Access/EmbargoAccessCheck.php @@ -74,6 +74,10 @@ public function access(EntityInterface $entity, AccountInterface $user) { )->render() ); array_map([$state, 'addCacheableDependency'], $embargoes); + + $type = $this->entityTypeManager->getDefinition('embargo'); + $state->addCacheTags($type->getListCacheTags()) + ->addCacheContexts($type->getListCacheContexts()); return $state; } diff --git a/src/Entity/Embargo.php b/src/Entity/Embargo.php index 581d798..e67f6ac 100644 --- a/src/Entity/Embargo.php +++ b/src/Entity/Embargo.php @@ -43,7 +43,8 @@ * "html" = "Drupal\Core\Entity\Routing\AdminHtmlRouteProvider" * }, * }, - * list_cache_tags = { "node_list", "media_list", "file_list" }, + * list_cache_contexts = { "ip.embargo_range", "user" }, + * list_cache_tags = { "embargo_list", "embargo_ip_range_list" }, * base_table = "embargo", * admin_permission = "administer embargo", * entity_keys = { @@ -451,4 +452,18 @@ public function ipIsExempt(string $ip): bool { return $exempt_ips && $exempt_ips->withinRanges($ip); } + /** + * {@inheritdoc} + */ + protected function getListCacheTagsToInvalidate() : array { + return array_merge( + parent::getListCacheTagsToInvalidate(), + [ + 'node_list', + 'media_list', + 'file_list', + ] + ); + } + }