Browse Source

Chequeo previo a deshabilitar/habilitar filtro soft_deleteable.

Maxi Schvindt 7 years ago
parent
commit
e5b681266f
1 changed files with 12 additions and 2 deletions
  1. 12 2
      Command/CRUDDeviceCommand.php

+ 12 - 2
Command/CRUDDeviceCommand.php

@@ -41,11 +41,18 @@ class CRUDDeviceCommand extends ContainerAwareCommand
         $method = $input->getOption('method');
         $username = $input->getOption('username');
         $password = $input->getOption('password');
+        $enabled = false;
         try {
             // busco por device type e id
             $container = $this->getContainer();
             $em = $container->get('doctrine.orm.entity_manager');
-            $em->getFilters()->disable('soft_deleteable');
+            //$em->getFilters()->disable('soft_deleteable');
+
+            if($em->getFilters()->isEnabled('soft_deleteable')) {
+                $enabled = true;
+                $em->getFilters()->disable('soft_deleteable');
+            }
+
             $repository = $em->getRepository($type);
             $entities = array();
             if (!empty($ids)) {
@@ -62,7 +69,10 @@ class CRUDDeviceCommand extends ContainerAwareCommand
             } else {
                 $entities = $repository->findAll();
             }
-            $em->getFilters()->enable('soft_deleteable');
+
+            if($enabled) {
+                $em->getFilters()->enable('soft_deleteable');
+            }
 
             // llamada POST para guardar el device
             if (!$url && $container->hasParameter('device_post_url')) {