Просмотр исходного кода

Modified the array to stdClass objects.

Jean Sumara Leopoldo 4 лет назад
Родитель
Сommit
9bffecd0b5
2 измененных файлов с 12 добавлено и 11 удалено
  1. 2 1
      composer.json
  2. 10 10
      src/App/Service/Stats/StatsService.php

+ 2 - 1
composer.json

@@ -22,7 +22,8 @@
     "ext-mbstring": "*",
     "ext-pdo": "*",
     "ocramius/package-versions": "1.2.0",
-    "vlucas/phpdotenv": "*"
+    "vlucas/phpdotenv": "*",
+    "ext-json": "*"
   },
   "autoload": {
     "psr-4": {

+ 10 - 10
src/App/Service/Stats/StatsService.php

@@ -303,24 +303,24 @@ class StatsService
 
         $data = array();
         foreach($onus as $k => $device) {
-            $extra = $device['extraData'];
+            $extra = json_decode($device['extra_data']);
 
-            if(isset($extra['ponSerialNumberAux'])) {
-                $sn = strtolower($extra['ponSerialNumberAux']);
+            if(isset($extra->ponSerialNumberAux)) {
+                $sn = strtolower($extra->ponSerialNumberAux);
                 $clientId = $lat = $lng = NULL;
 
-                if(isset($extra['location']) && isset($extra['location']['extraData'])){
-                    if(isset($extra['location']['extraData']['lat'])){
-                        $lat = $extra['location']['extraData']['lat'];
+                if(isset($extra->location) && isset($extra->location->extraData)){
+                    if(isset($extra->location->extraData->lat)){
+                        $lat = $extra->location->extraData->lat;
                     }
 
-                    if(isset($extra['location']['extraData']['lng'])){
-                        $lng = $extra['location']['extraData']['lng'];
+                    if(isset($extra->location->extraData->lng)){
+                        $lng = $extra->location->extraData->lng;
                     }
                 }
 
-                if(isset($extra['clientId'])){
-                    $clientId = $extra['clientId'];
+                if(isset($extra->clientId)){
+                    $clientId = $extra->clientId;
                 }
 
                 $data[$sn] = array('deviceId' => $device['device_id'], 'lat' => $lat, 'lng' => $lng, 'clientId' => $clientId);