|
@@ -94,10 +94,31 @@ class DeviceListener
|
|
$entity = $args->getEntity();
|
|
$entity = $args->getEntity();
|
|
if ($entity instanceof DeviceInterface) {
|
|
if ($entity instanceof DeviceInterface) {
|
|
$data = $entity->getDeviceData();
|
|
$data = $entity->getDeviceData();
|
|
-
|
|
|
|
|
|
+ $data = $this->addLocationData($entity, $data);
|
|
|
|
+
|
|
return $this->webservice->makeGetRequest($url, $method, $data);
|
|
return $this->webservice->makeGetRequest($url, $method, $data);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Agrega la ubicación de $entity si implementa LocationInterface
|
|
|
|
+ *
|
|
|
|
+ * @param Entity $entity
|
|
|
|
+ * @param array $data
|
|
|
|
+ *
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
|
|
+ private function addLocationData($entity, $data)
|
|
|
|
+ {
|
|
|
|
+ $locationInterface = 'MapBundle\Entity\Interfaces\LocationInterface';
|
|
|
|
+ if (interface_exists($locationInterface) && is_a($entity, $locationInterface)) {
|
|
|
|
+ $extraData = json_decode($data['extraData'], true);
|
|
|
|
+ $extraData['location'] = $entity->getLocation() ? $entity->getLocation()->getData() : array();
|
|
|
|
+ $data['extraData'] = json_encode($extraData);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $data;
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* @param object $entity
|
|
* @param object $entity
|
|
@@ -112,7 +133,7 @@ class DeviceListener
|
|
$filters = array('deviceId'=>$deviceId,'deviceType'=>$deviceType,'tenancyId'=>$tenancyId);
|
|
$filters = array('deviceId'=>$deviceId,'deviceType'=>$deviceType,'tenancyId'=>$tenancyId);
|
|
$data = $this->webservice->getData("device_post_url",$filters);
|
|
$data = $this->webservice->getData("device_post_url",$filters);
|
|
|
|
|
|
- file_put_contents("/var/flowdat/error.log",json_encode($data));
|
|
|
|
|
|
+// file_put_contents("/var/flowdat/error.log",json_encode($data));
|
|
|
|
|
|
$deviceId = null;
|
|
$deviceId = null;
|
|
if(isset($data[0]))
|
|
if(isset($data[0]))
|