From 64939da6d89c59ee3db1aadb9bd15aa1737044c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Fromme?= Date: Tue, 28 Jan 2020 10:16:30 +0100 Subject: [PATCH] Exclude unavailable webcams from import and set status accordingly in db --- .../Classes/Service/SnowreportImportService.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/public/typo3conf/ext/ep_products/Classes/Service/SnowreportImportService.php b/public/typo3conf/ext/ep_products/Classes/Service/SnowreportImportService.php index 0bd69778..85b09ce1 100644 --- a/public/typo3conf/ext/ep_products/Classes/Service/SnowreportImportService.php +++ b/public/typo3conf/ext/ep_products/Classes/Service/SnowreportImportService.php @@ -205,22 +205,30 @@ class SnowreportImportService implements SingletonInterface $snowReportStoragePid = SettingsUtility::get('snowReportStoragePid'); foreach ($xml->children() as $item) { + $include = (string) $item->aktuell === 'true'; + $available = (string) $item->verf === 'true'; $vendorUid = (int) $item->uid; $result = $this->webcamRepository->findByVendorUid($vendorUid); + // Skip invalid cams + if ($include === false && $result->count() === 0) { + continue; + } + // Add new cam if not in db yet if ($result->count() === 0) { $webcam = new Webcam(); $webcam->setVendorUid($vendorUid); $webcam->setPid($snowReportStoragePid); $webcam->setUrl((string) $item->url); $webcam->setName((string) $item->dt); - $webcam->setAvailable((string) $item->verf === 'true'); + $webcam->setAvailable($available); $this->webcamRepository->add($webcam); $snowreport->addWebcam($webcam); } else { + // Update cam in db and set availability $webcam = $result->getFirst(); $webcam->setUrl((string) $item->url); $webcam->setName((string) $item->dt); - $webcam->setAvailable((string) $item->verf === 'true'); + $webcam->setAvailable($available && $include); } static::$validWebcamUids[] = $vendorUid; }