public function ParserService::getWeather in Weather 8
Same name and namespace in other branches
- 2.0.x src/Service/ParserService.php \Drupal\weather\Service\ParserService::getWeather()
Returns a weather object for the specified GeoID.
Parameters
string $geoid: GeoID of the place for which the weather is desired.
int $days: Return weather for specified number of days (0 = all available days).
bool $detailed: Return detailed forecasts or just one forecast per day.
Return value
array Weather array with forecast information.
File
- src/
Service/ ParserService.php, line 419
Class
- ParserService
- ParserService service.
Namespace
Drupal\weather\ServiceCode
public function getWeather($geoid, $days = 0, $detailed = TRUE) {
// We need this variable for tests in future.
$time = time();
// Make sure weather forecast for this GeoID exists in DB.
$result = $this
->downloadWeather($geoid, $time);
// Get weather from DB.
$weather['forecasts'] = $this
->getForecastsFromDatabase($geoid, $result['utc_offset'], $days, $detailed, $time);
$weather['utc_offset'] = $result['utc_offset'];
return $weather;
}