Skip to content

Commit

Permalink
Module: data provider: make sure there is always a lat/lon (#2559)
Browse files Browse the repository at this point in the history
* Module: make sure there is always a lat/lon in the data provider
xibosignage/xibo#3428
  • Loading branch information
dasgarner authored Jun 10, 2024
1 parent eb40d5d commit 6e9f12e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lib/Connector/OpenWeatherMapConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ private function getWeatherData(DataProviderInterface $dataProvider)
}

// Build the URL
$url = '?lat=' . ($providedLat ?? '')
. '&lon=' . ($providedLon ?? '')
$url = '?lat=' . $providedLat
. '&lon=' . $providedLon
. '&units=' . $units
. '&lang=' . $dataProvider->getProperty('lang', 'en')
. '&appid=[API_KEY]';
Expand Down
13 changes: 5 additions & 8 deletions lib/XTR/WidgetSyncTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,11 @@ private function cache(
$dataProvider->setMediaFactory($this->mediaFactory);

// Set our provider up for the display
if ($display !== null) {
$dataProvider->setDisplayProperties($display->latitude, $display->longitude, $display->displayId);
} else {
$dataProvider->setDisplayProperties(
$this->getConfig()->getSetting('DEFAULT_LAT'),
$this->getConfig()->getSetting('DEFAULT_LONG')
);
}
$dataProvider->setDisplayProperties(
$display?->latitude ?: $this->getConfig()->getSetting('DEFAULT_LAT'),
$display?->longitude ?: $this->getConfig()->getSetting('DEFAULT_LONG'),
$display?->displayId ?? 0
);

$widgetDataProviderCache = $this->moduleFactory->createWidgetDataProviderCache();

Expand Down
8 changes: 4 additions & 4 deletions lib/Xmds/Soap.php
Original file line number Diff line number Diff line change
Expand Up @@ -928,8 +928,8 @@ protected function doRequiredFiles(
// this region?
$dataProvider = $dataModule->createDataProvider($widget);
$dataProvider->setDisplayProperties(
$this->display->latitude,
$this->display->longitude,
$this->display->latitude ?: $this->getConfig()->getSetting('DEFAULT_LAT'),
$this->display->longitude ?: $this->getConfig()->getSetting('DEFAULT_LONG'),
$this->display->displayId
);

Expand Down Expand Up @@ -2375,8 +2375,8 @@ protected function doGetResource(
// We only ever return cache.
$dataProvider = $dataModule->createDataProvider($widget);
$dataProvider->setDisplayProperties(
$this->display->latitude,
$this->display->longitude,
$this->display->latitude ?: $this->getConfig()->getSetting('DEFAULT_LAT'),
$this->display->longitude ?: $this->getConfig()->getSetting('DEFAULT_LONG'),
$this->display->displayId
);

Expand Down
4 changes: 2 additions & 2 deletions lib/Xmds/Soap7.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ public function GetData($serverKey, $hardwareKey, $widgetId)
// We only ever return cache.
$dataProvider = $module->createDataProvider($widget);
$dataProvider->setDisplayProperties(
$this->display->latitude,
$this->display->longitude,
$this->display->latitude ?: $this->getConfig()->getSetting('DEFAULT_LAT'),
$this->display->longitude ?: $this->getConfig()->getSetting('DEFAULT_LONG'),
$this->display->displayId
);

Expand Down

0 comments on commit 6e9f12e

Please sign in to comment.