瀏覽代碼

Modificado solo DeviceListener para no enviar actualizaciones en postPersist o postUpdate de elementos softDelete.

Maxi Schvindt 7 年之前
父節點
當前提交
5ff7b53da7
共有 3 個文件被更改,包括 20 次插入1 次删除
  1. 2 0
      Command/CRUDDeviceCommand.php
  2. 18 0
      EventListener/DeviceListener.php
  3. 0 1
      Interfaces/DeviceInterface.php

+ 2 - 0
Command/CRUDDeviceCommand.php

@@ -7,6 +7,7 @@ use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Output\OutputInterface;
 use Buzz\Message\RequestInterface as HttpRequestInterface;
+use Base\AdminBundle\Interfaces\SoftDeleteInterface;
 
 class CRUDDeviceCommand extends ContainerAwareCommand
 {
@@ -69,6 +70,7 @@ class CRUDDeviceCommand extends ContainerAwareCommand
             }
             $deviceListener = $container->get('device.device_listener');
             foreach ($entities as $entity) {
+                
                 $response = $deviceListener->send($entity, $url, $method, compact('username', 'password'));
                 if (json_decode($response)) {
                     if ($method == HttpRequestInterface::METHOD_POST) {

+ 18 - 0
EventListener/DeviceListener.php

@@ -9,6 +9,7 @@ use Buzz\Message\RequestInterface as HttpRequestInterface;
 use Symfony\Bundle\FrameworkBundle\Console\Application;
 use Symfony\Component\Console\Input\ArrayInput;
 use Symfony\Component\Console\Output\BufferedOutput;
+use Base\AdminBundle\Interfaces\SoftDeleteInterface;
 
 class DeviceListener
 {
@@ -63,6 +64,11 @@ class DeviceListener
         }
 
         $entity = $args->getEntity();
+
+        if($entity instanceof SoftDeleteInterface && $entity->isDeleted()) {
+            return;  
+        } 
+        
         if ($entity instanceof DeviceInterface) {
             $cmd_args = array(
                 '--type:' . get_class($entity),
@@ -85,6 +91,7 @@ class DeviceListener
      */
     public function runCommand($name, $cmd_args = array())
     {
+
         $kernel = $this->serviceContainer->get('kernel');
         
         $application = new Application($kernel);
@@ -116,7 +123,9 @@ class DeviceListener
         }
 
         $entity = $args->getEntity();
+
         if ($entity instanceof DeviceInterface) {
+            var_dump(get_class($entity).PHP_EOL);
             if ($deviceId = $this->getRemoteDeviceId($entity)) {
                 $cmd_args = array(
                     '--type:' . get_class($entity),
@@ -128,6 +137,8 @@ class DeviceListener
                 return $this->runCommand('device:crud', $cmd_args);
             }
         }
+
+        return;
     }
 
     /**
@@ -140,6 +151,11 @@ class DeviceListener
         }
 
         $entity = $args->getEntity();
+
+        if($entity instanceof SoftDeleteInterface && $entity->isDeleted()) {
+            return;  
+        } 
+
         if ($entity instanceof DeviceInterface) {
             $cmd_args = array(
                 '--type:' . get_class($entity),
@@ -152,6 +168,8 @@ class DeviceListener
             
             return $this->runCommand('device:crud', $cmd_args);
         }
+
+        return;
     }
 
     /**

+ 0 - 1
Interfaces/DeviceInterface.php

@@ -4,6 +4,5 @@ namespace DeviceBundle\Interfaces;
 
 interface DeviceInterface
 {
-
     public function getDeviceData();
 }