public function dispatch(Request $request, Response $response, $args)
 {
     $this->id = $args['id'];
     //        $this->logger->info("[" . $this->id . "] - Get data with the weather forecast");
     FileSystemCache::$cacheDir = './cache/tmp';
     $key = FileSystemCache::generateCacheKey('cache-feed-' . $this->id, null);
     $data = FileSystemCache::retrieve($key);
     if ($data === false) {
         $this->data_json = array('datetime' => json_decode(file_get_contents('http://dsx.weather.com/cs/v2/datetime/' . $this->locale . '/' . $args['id'] . ':1:BR'), true), 'now' => json_decode(file_get_contents('http://dsx.weather.com/wxd/v2/MORecord/' . $this->locale . '/' . $args['id'] . ':1:BR'), true), 'forecasts' => json_decode(file_get_contents('http://dsx.weather.com/wxd/v2/15DayForecast/' . $this->locale . '/' . $args['id'] . ':1:BR'), true));
         $data = array('info' => $this->processInfo(), 'now' => $this->processNow(), 'forecasts' => $this->processForecast());
         FileSystemCache::store($key, $data, 1800);
     } else {
         //            $this->logger->info("[" . $this->id . "] - Using cache to generate xml");
     }
     $xmlBuilder = new XmlBuilder('root');
     $xmlBuilder->setSingularizer(function ($name) {
         if ('forecasts' === $name) {
             return 'item';
         }
         return $name;
     });
     $xmlBuilder->load($data);
     $xml_output = $xmlBuilder->createXML(true);
     $response->write($xml_output);
     $response = $response->withHeader('content-type', 'text/xml');
     return $response;
 }