src/fwidm/dwdHourlyCrawler/hourly/DWDHourlyCrawler.php
public function getStations(AbstractHourlyService $controller, bool $activeOnly = false, bool $forceDownloadFile = false)
    {
        $downloadFile = false || $forceDownloadFile;
        $stationsFTPPath = DWDConfiguration::getHourlyConfiguration()->parameters;
        $stationsFTPPath = get_object_vars($stationsFTPPath)[$controller->getParameter()]->stations;

        $filePath = $controller->getStationFTPPath($stationsFTPPath);
        //Retrieve Stations
        if (file_exists($filePath)) {
            $lastModifiedStationFile = Carbon::createFromTimestamp(filemtime($filePath));
            $diffInHours = Carbon::now()->diffInHours(Carbon::createFromTimestamp(filemtime($filePath)));
            DWDUtil::log(self::class, "last modified? " . $lastModifiedStationFile
                . "; difference to today (h)? " . $diffInHours);
            $downloadFile = $diffInHours >= 12; //redownload every 12h.
        } else
            $downloadFile = true;
        //todo: determine if this works - had a problem where this did not trigger redownloading of the file, which lead to the no active stations exception.
        if ($downloadFile) {
            DWDUtil::log(self::class, "Downloading station file=" . $filePath);
            DWDStationsController::getStationFile($stationsFTPPath, $filePath);
        }

        $stations = DWDStationsController::parseStations($filePath);
        DWDUtil::log(self::class, "Got stations... " . count($stations));

        //todo 31.8.2017:  rewrite the "active" part in a way that checks if the queried date is inside the "active" period of stations
        if ($activeOnly && count($stations) > 0) {
            $stations = array_filter($stations,
                function (DWDStation $station) {
                    return $station->isActive();
                });
        }
        DWDUtil::log(self::class, "Got stations after filtering... " . count($stations));

        return $stations;
    }
public function getStations(AbstractHourlyService $controller, bool $activeOnly = false, bool $forceDownloadFile = false)
    {
        $downloadFile = false || $forceDownloadFile;
        $stationsFTPPath = DWDConfiguration::getHourlyConfiguration()->parameters;
        $stationsFTPPath = get_object_vars($stationsFTPPath)[$controller->getParameter()]->stations;

        $filePath = $controller->getStationFTPPath($stationsFTPPath);
        //Retrieve Stations
        if (file_exists($filePath)) {
            $lastModifiedStationFile = Carbon::createFromTimestamp(filemtime($filePath));
            $diffInHours = Carbon::now()->diffInHours(Carbon::createFromTimestamp(filemtime($filePath)));
            DWDUtil::log(self::class, "last modified? " . $lastModifiedStationFile
                . "; difference to today (h)? " . $diffInHours);
            $downloadFile = $diffInHours >= 12; //redownload every 12h.
        } else
            $downloadFile = true;
        //todo: determine if this works - had a problem where this did not trigger redownloading of the file, which lead to the no active stations exception.
        if ($downloadFile) {
            DWDUtil::log(self::class, "Downloading station file=" . $filePath);
            DWDStationsController::getStationFile($stationsFTPPath, $filePath);
        }

        $stations = DWDStationsController::parseStations($filePath);
        DWDUtil::log(self::class, "Got stations... " . count($stations));

        //todo 31.8.2017:  rewrite the "active" part in a way that checks if the queried date is inside the "active" period of stations
        if ($activeOnly && count($stations) > 0) {
            $stations = array_filter($stations,
                function (DWDStation $station) {
                    return $station->isActive();
                });
        }
        DWDUtil::log(self::class, "Got stations after filtering... " . count($stations));

        return $stations;
    }
public function getStations ( AbstractHourlyService $ controller , bool $ activeOnly = false , bool $ forceDownloadFile = false ) { $ downloadFile = false || $ forceDownloadFile ; $ stationsFTPPath = DWDConfiguration :: getHourlyConfiguration ( ) -> parameters ; $ stationsFTPPath = get_object_vars ( $ stationsFTPPath ) [ $ controller -> getParameter ( ) ] -> stations ; $ filePath = $ controller -> getStationFTPPath ( $ stationsFTPPath ) ; //Retrieve Stations if ( file_exists ( $ filePath ) ) { $ lastModifiedStationFile = Carbon :: createFromTimestamp ( filemtime ( $ filePath ) ) ; $ diffInHours = Carbon :: now ( ) -> diffInHours ( Carbon :: createFromTimestamp ( filemtime ( $ filePath ) ) ) ; DWDUtil :: log ( self :: class , "last modified? " . $ lastModifiedStationFile . "; difference to today (h)? " . $ diffInHours ) ; $ downloadFile = $ diffInHours >= 12 ; //redownload every 12h. } else $ downloadFile = true ; //todo: determine if this works - had a problem where this did not trigger redownloading of the file, which lead to the no active stations exception. if ( $ downloadFile ) { DWDUtil :: log ( self :: class , "Downloading station file=" . $ filePath ) ; DWDStationsController :: getStationFile ( $ stationsFTPPath , $ filePath ) ; } $ stations = DWDStationsController :: parseStations ( $ filePath ) ; DWDUtil :: log ( self :: class , "Got stations... " . count ( $ stations ) ) ; //todo 31.8.2017:  rewrite the "active" part in a way that checks if the queried date is inside the "active" period of stations if ( $ activeOnly && count ( $ stations ) > 0 ) { $ stations = array_filter ( $ stations , function ( DWDStation $ station ) { return $ station -> isActive ( ) ; } ) ; } DWDUtil :: log ( self :: class , "Got stations after filtering... " . count ( $ stations ) ) ; return $ stations ; }
Retrieves the correct stations file, can be filtered to only show stations that are flagges as active. Conditions
for this can be
@param bool $activeOnly
@return array
Retrieves the correct stations file can be filtered to only show stations that are flagges as active . Conditions for this can be