You are here

public function WeatherDisplayBlockTrait::getCacheTags in Weather 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/Block/WeatherDisplayBlockTrait.php \Drupal\weather\Plugin\Block\WeatherDisplayBlockTrait::getCacheTags()

File

src/Plugin/Block/WeatherDisplayBlockTrait.php, line 80

Class

WeatherDisplayBlockTrait
Provides reusable functions for weather block plugins.

Namespace

Drupal\weather\Plugin\Block

Code

public function getCacheTags() {

  // Update this block after related weather_display
  // or one of related weather_display_places updated.
  $parent = parent::getCacheTags();
  $displayTags = $this->weatherDisplay
    ->getCacheTags();
  $tags = Cache::mergeTags($parent, $displayTags);
  $display_places = $this->weatherDisplayPlaceStorage
    ->loadByProperties([
    'display_type' => $this->weatherDisplay->type->value,
    'display_number' => $this->weatherDisplay->number->value,
  ]);
  foreach ($display_places as $display_place) {
    $tags = Cache::mergeTags($tags, $display_place
      ->getCacheTags());
  }

  // Depends on weather module settings also.
  $tags = Cache::mergeTags($tags, [
    'config:weather.settings',
  ]);
  return $tags;
}