From 1a4438166024d8271046f20703a0e593a76fad22 Mon Sep 17 00:00:00 2001 From: Duane Griffin Date: Thu, 25 Jul 2024 20:23:45 +1200 Subject: [PATCH] eve-scout: fix thera routes (#221) It appears the data returned from the code that mediates access to the EVE Scout Thera connections data is now returning an array instead of an object. Update the code to retrieve the contents accordingly. Also correctly initialise the empty jump nodes list when creating a new system entry. --- app/Controller/Api/Rest/Route.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/app/Controller/Api/Rest/Route.php b/app/Controller/Api/Rest/Route.php index b013cac5d..b06073f92 100644 --- a/app/Controller/Api/Rest/Route.php +++ b/app/Controller/Api/Rest/Route.php @@ -274,21 +274,22 @@ private function setTheraJumpData(){ $enrichJumpData = function(array &$row, string $systemSourceKey, string $systemTargetKey) use (&$jumpData) { // check if response data is valid if( - is_object($systemSource = $row[$systemSourceKey]) && !empty((array)$systemSource) && - is_object($systemTarget = $row[$systemTargetKey]) && !empty((array)$systemTarget) + is_array($systemSource = $row[$systemSourceKey]) && !empty($systemSource) && + is_array($systemTarget = $row[$systemTargetKey]) && !empty($systemTarget) ){ - if(!array_key_exists($systemSource->id, $jumpData)){ - $jumpData[$systemSource->id] = [ - 'systemId' => (int)$systemSource->id, - 'systemName' => $systemSource->name, - 'constellationId' => (int)$systemSource->constellationID, - 'regionId' => (int)$systemSource->regionId, - 'trueSec' => $systemSource->security, + $srcId = $systemSource['id']; + $targetId = $systemTarget['id']; + if(!array_key_exists($srcId, $jumpData)){ + $jumpData[$srcId] = [ + 'systemId' => $srcId, + 'systemName' => $systemSource['name'], + 'jumpNodes' => [], ]; } - if( !in_array((int)$systemTarget->id, (array)$jumpData[$systemSource->id]['jumpNodes']) ){ - $jumpData[$systemSource->id]['jumpNodes'][] = (int)$systemTarget->id; + $jumpNodes = $jumpData[$srcId]['jumpNodes']; + if( !in_array($targetId, $jumpData[$srcId]['jumpNodes']) ){ + $jumpData[$srcId]['jumpNodes'][] = $targetId; } } }; @@ -865,4 +866,4 @@ public function post(\Base $f3){ $this->out($return); } -} \ No newline at end of file +}