Browse Source

Se agrega chequeo de uso de DeviceInterface para el preRemove y se habilita/deshabilita filtro softDelete en CRUDDeviceCommand para obtener elementos "borrados" a la hora de enviar la eliminación hacia el Base.

Maxi Schvindt 7 năm trước cách đây
mục cha
commit
b25da284a6
2 tập tin đã thay đổi với 16 bổ sung12 xóa
  1. 2 0
      Command/CRUDDeviceCommand.php
  2. 14 12
      EventListener/DeviceListener.php

+ 2 - 0
Command/CRUDDeviceCommand.php

@@ -42,6 +42,7 @@ class CRUDDeviceCommand extends ContainerAwareCommand
             // busco por device type e id
             $container = $this->getContainer();
             $em = $container->get('doctrine.orm.entity_manager');
+            $em->getFilters()->disable('soft_deleteable');
             $repository = $em->getRepository($type);
             $entities = array();
             if (!empty($ids)) {
@@ -58,6 +59,7 @@ class CRUDDeviceCommand extends ContainerAwareCommand
             } else {
                 $entities = $repository->findAll();
             }
+            $em->getFilters()->enable('soft_deleteable');
 
             // llamada POST para guardar el device
             if (!$url && $container->hasParameter('device_post_url')) {

+ 14 - 12
EventListener/DeviceListener.php

@@ -63,12 +63,15 @@ class DeviceListener
         }
 
         $entity = $args->getEntity();
-        $cmd_args = array(
-            '--type:' . get_class($entity),
-            '--id:' . $entity->getId(),
-        );
+        if ($entity instanceof DeviceInterface) {
+            $cmd_args = array(
+                '--type:' . get_class($entity),
+                '--id:' . $entity->getId(),
+            );
+            
+            return $this->runCommand('device:crud', $cmd_args);
+        }
         
-        return $this->runCommand('device:crud', $cmd_args);
     }
     
     /**
@@ -88,13 +91,14 @@ class DeviceListener
         $application->setAutoExit(false);
         
         $input = new ArrayInput(array(
-           'command' => 'amqp:remote',
-           'name' => $name,
-           '--args' => $cmd_args,
-           '--route' => getenv("AMQP_KEY"),
+            'command' => 'amqp:remote',
+            'name' => $name,
+            '--args' => $cmd_args,
+            '--route' => getenv("AMQP_KEY"),
         ));
         
         $output = new BufferedOutput();
+        
         $application->run($input, $output);
 
         return $output->fetch();
@@ -120,7 +124,7 @@ class DeviceListener
                     '--url:' . $this->deviceDeletePostUrl . $deviceId,
                     '--method:' . HttpRequestInterface::METHOD_DELETE,
                 );
-                
+
                 return $this->runCommand('device:crud', $cmd_args);
             }
         }
@@ -218,8 +222,6 @@ class DeviceListener
         );
         $data = $this->webservice->getData("device_post_url", $filters);
 
-//        file_put_contents("/var/flowdat/error.log",json_encode($data));
-
         $deviceId = null;
         if (isset($data[0])) {
             $deviceId = $data[0]['id'];