protected function ThemeService::setWeatherVariables in Weather 2.0.x
Same name and namespace in other branches
- 8 src/Service/ThemeService.php \Drupal\weather\Service\ThemeService::setWeatherVariables()
Adds basic weather variables.
1 call to ThemeService::setWeatherVariables()
- ThemeService::preprocessWeatherVariables in src/
Service/ ThemeService.php - Prepare variables to render weather display.
File
- src/
Service/ ThemeService.php, line 137
Class
- ThemeService
- Prepare forecast data for displaying.
Namespace
Drupal\weather\ServiceCode
protected function setWeatherVariables(&$variables, $idx, $place, $weather, bool $detailed = FALSE) {
$variables['weather'][$idx]['utc_offset'] = $weather['utc_offset'];
$variables['weather'][$idx]['name'] = $place->displayed_name->value;
$variables['weather'][$idx]['geoid'] = $place->geoid->target_id;
if (!$detailed) {
$link = $this->weatherHelper
->getLinkForGeoid($place->geoid->target_id, $variables['destination'], $variables['display_number']);
$variables['weather'][$idx]['link'] = Link::fromTextAndUrl($place->displayed_name->value, Url::fromUserInput($link));
}
$link = $this->weatherHelper
->getLinkForGeoid($place->geoid->target_id, 'yr.no');
$variables['weather'][$idx]['yr.no'] = $link;
}