Exclude unavailable webcams from import and set status accordingly in db
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user