public function ThemeService::preprocessWeatherVariables in Weather 8
Same name and namespace in other branches
- 2.0.x src/Service/ThemeService.php \Drupal\weather\Service\ThemeService::preprocessWeatherVariables()
Prepare variables to render weather display.
File
- src/
Service/ ThemeService.php, line 111
Class
- ThemeService
- ThemeService service.
Namespace
Drupal\weather\ServiceCode
public function preprocessWeatherVariables(&$variables, bool $detailed = FALSE) {
$displayPlaces = [];
$forecast_days = $this->weatherConfig
->get('weather_forecast_days');
$display = $this->weatherHelper
->getDisplayConfig($variables['display_type'], $variables['display_number']);
// On detailed forecast page we show only 1 place.
if ($detailed) {
if ($variables['weather_display_place'] instanceof WeatherDisplayPlaceInterface) {
$displayPlaces = [
$variables['weather_display_place'],
];
$forecast_days = 0;
}
}
else {
$displayPlaces = $this->weatherHelper
->getPlacesInUse($variables['display_type'], $variables['display_number']);
}
foreach ($displayPlaces as $idx => $place) {
$weather = $this->weatherParser
->getWeather($place->geoid->target_id, $forecast_days, $detailed);
$this
->setWeatherVariables($variables, $idx, $place, $weather, $detailed);
$this
->setForecastsVariables($variables, $idx, $weather, $display);
}
}