Skip to content

Commit

Permalink
Remove $this->addCacheContexts($contexts) as returning by merging wit…
Browse files Browse the repository at this point in the history
…h parent

- This follows what Drupal core / modules do
  • Loading branch information
andybroomfield committed Jul 2, 2021
1 parent 04a5747 commit 06ab96b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/Entity/AlertBannerEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
*/
public function getCacheContexts() {

// Add front page context for front page classes.
$contexts = ['url.path.is_front'];

// Add cache contexts depending on the enabled visibility condition plugins.
Expand All @@ -406,11 +407,8 @@ public function getCacheContexts() {
}
}

// Add to the main cache contexts.
$this->addCacheContexts($contexts);

// Return cache contexts.
return parent::getCacheContexts();
return Cache::mergeContexts(parent::getCacheContexts(), $contexts);
}

/**
Expand All @@ -420,7 +418,7 @@ public function getCacheTags() {

// Get token and use as a cache tag.
$token = $this->getToken();
$cache_tags = ['localgov.alert.banner.token:' . $token];;
$cache_tags = ['localgov.alert.banner.token:' . $token];

return Cache::mergeTags(parent::getCacheTags(), $cache_tags);
}
Expand Down

0 comments on commit 06ab96b

Please sign in to comment.