public function WeatherDisplayBlockTrait::build in Weather 8
Same name and namespace in other branches
- 2.0.x src/Plugin/Block/WeatherDisplayBlockTrait.php \Drupal\weather\Plugin\Block\WeatherDisplayBlockTrait::build()
File
- src/
Plugin/ Block/ WeatherDisplayBlockTrait.php, line 51
Class
- WeatherDisplayBlockTrait
- Provides reusable functions for weather block plugins.
Namespace
Drupal\weather\Plugin\BlockCode
public function build() {
if (!$this->weatherDisplay instanceof WeatherDisplayInterface) {
return [];
}
$type = $this->weatherDisplay->type->value;
$number = $this->weatherDisplay->number->value;
$display_places = $this->weatherDisplayPlaceStorage
->loadByProperties([
'display_type' => $type,
'display_number' => $number,
]);
if (empty($display_places)) {
return [];
}
$build = [
'#theme' => 'weather',
'#display_type' => $type,
'#display_number' => $number,
'#destination' => $this->destination,
];
return $build;
}