Skip to content

Commit

Permalink
Merge pull request #329 from localgovdrupal/1.x
Browse files Browse the repository at this point in the history
1.7.7 release
  • Loading branch information
finnlewis committed Jun 4, 2024
2 parents 25fb412 + 427d5f6 commit 89d03a6
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Plugin/Block/AlertBannerBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ public function build() {

// Render the alert banner.
$build = [];
$contexts = [];
foreach ($published_alert_banners as $alert_banner) {
$contexts = Cache::mergeContexts($contexts, $alert_banner->getCacheContexts());

// Only add to the build if it is visible.
// @see #154.
Expand All @@ -157,7 +155,6 @@ public function build() {
->view($alert_banner);
}
}
$build['#cache']['contexts'] = $contexts;
return $build;
}

Expand Down Expand Up @@ -227,6 +224,17 @@ protected function mapTypesConfigToQuery() : array {
});
}

/**
* {@inheritdoc}
*/
public function getCacheContexts() {
$contexts = [];
foreach ($this->getCurrentAlertBanners() as $alert_banner) {
$contexts = Cache::mergeContexts($contexts, $alert_banner->getCacheContexts());
}
return Cache::mergeContexts(parent::getCacheContexts(), $contexts);
}

/**
* {@inheritdoc}
*/
Expand Down

0 comments on commit 89d03a6

Please sign in to comment.