|
@@ -42,6 +42,7 @@ class DeviceListener
|
|
$this->devicePostUrl = $devicePostUrl;
|
|
$this->devicePostUrl = $devicePostUrl;
|
|
$this->deviceDeletePostUrl = $deviceDeletePostUrl;
|
|
$this->deviceDeletePostUrl = $deviceDeletePostUrl;
|
|
$this->devicePutUrl = $devicePutUrl;
|
|
$this->devicePutUrl = $devicePutUrl;
|
|
|
|
+ $this->enabled = true;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -49,7 +50,9 @@ class DeviceListener
|
|
*/
|
|
*/
|
|
public function postPersist(LifecycleEventArgs $args)
|
|
public function postPersist(LifecycleEventArgs $args)
|
|
{
|
|
{
|
|
- $this->send($args, $this->devicePostUrl, HttpRequestInterface::METHOD_POST);
|
|
|
|
|
|
+ if(!$this->enabled) return ;
|
|
|
|
+
|
|
|
|
+ $this->send($args, $this->devicePostUrl, HttpRequestInterface::METHOD_POST);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -57,6 +60,8 @@ class DeviceListener
|
|
*/
|
|
*/
|
|
public function preRemove(LifecycleEventArgs $args)
|
|
public function preRemove(LifecycleEventArgs $args)
|
|
{
|
|
{
|
|
|
|
+ if(!$this->enabled) return ;
|
|
|
|
+
|
|
$entity = $args->getEntity();
|
|
$entity = $args->getEntity();
|
|
if ($entity instanceof DeviceInterface) {
|
|
if ($entity instanceof DeviceInterface) {
|
|
if($deviceId = $this->getRemoteDeviceId($entity)) {
|
|
if($deviceId = $this->getRemoteDeviceId($entity)) {
|
|
@@ -72,6 +77,8 @@ class DeviceListener
|
|
*/
|
|
*/
|
|
public function postUpdate(LifecycleEventArgs $args)
|
|
public function postUpdate(LifecycleEventArgs $args)
|
|
{
|
|
{
|
|
|
|
+ if(!$this->enabled) return ;
|
|
|
|
+
|
|
$entity = $args->getEntity();
|
|
$entity = $args->getEntity();
|
|
if ($entity instanceof DeviceInterface) {
|
|
if ($entity instanceof DeviceInterface) {
|
|
if($deviceId = $this->getRemoteDeviceId($entity)) {
|
|
if($deviceId = $this->getRemoteDeviceId($entity)) {
|
|
@@ -91,6 +98,8 @@ class DeviceListener
|
|
*/
|
|
*/
|
|
private function send(LifecycleEventArgs $args, $url, $method)
|
|
private function send(LifecycleEventArgs $args, $url, $method)
|
|
{
|
|
{
|
|
|
|
+ if(!$this->enabled) return ;
|
|
|
|
+
|
|
$entity = $args->getEntity();
|
|
$entity = $args->getEntity();
|
|
if ($entity instanceof DeviceInterface) {
|
|
if ($entity instanceof DeviceInterface) {
|
|
$data = $entity->getDeviceData();
|
|
$data = $entity->getDeviceData();
|
|
@@ -110,6 +119,8 @@ class DeviceListener
|
|
*/
|
|
*/
|
|
private function addLocationData($entity, $data)
|
|
private function addLocationData($entity, $data)
|
|
{
|
|
{
|
|
|
|
+ $this->enabled = true;
|
|
|
|
+
|
|
$locationInterface = 'MapBundle\Entity\Interfaces\LocationInterface';
|
|
$locationInterface = 'MapBundle\Entity\Interfaces\LocationInterface';
|
|
if (interface_exists($locationInterface) && is_a($entity, $locationInterface)) {
|
|
if (interface_exists($locationInterface) && is_a($entity, $locationInterface)) {
|
|
$extraData = json_decode($data['extraData'], true);
|
|
$extraData = json_decode($data['extraData'], true);
|
|
@@ -125,6 +136,8 @@ class DeviceListener
|
|
*/
|
|
*/
|
|
private function getRemoteDeviceId($entity)
|
|
private function getRemoteDeviceId($entity)
|
|
{
|
|
{
|
|
|
|
+ $this->enabled = true;
|
|
|
|
+
|
|
$deviceId = $entity->getId();
|
|
$deviceId = $entity->getId();
|
|
$deviceType = get_class($entity);
|
|
$deviceType = get_class($entity);
|
|
$tenancyId = $entity->getTenancyId();
|
|
$tenancyId = $entity->getTenancyId();
|
|
@@ -142,4 +155,8 @@ class DeviceListener
|
|
return $deviceId;
|
|
return $deviceId;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ function remoteCheck($enabled = true){
|
|
|
|
+ $this->enabled = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|