Ver código fonte

Se actualiza comando workflow:default

Espinoza Guillermo 6 anos atrás
pai
commit
68b4100b11
1 arquivos alterados com 12 adições e 5 exclusões
  1. 12 5
      Command/WorkflowDefaultCommand.php

+ 12 - 5
Command/WorkflowDefaultCommand.php

@@ -64,13 +64,20 @@ class WorkflowDefaultCommand extends ContainerAwareCommand
         }
         
         if (!is_null($workflow) && $input->getOption('all')) {
+            // actualizo las onus que no tengan currentState.
+            // por ej si fueron  importadas
             $qb = $em->getRepository($class)->createQueryBuilder($class);
             $result = $qb->update($class, 'o')
-            ->set('o.workflow', ':workflow')
-            ->setParameter('workflow', $workflow)
-            ->getQuery()
-            ->getResult()
-            ;
+                    ->set('o.currentState', ':currentState')
+                    ->setParameter('currentState', 'active')
+                    ->where('o.currentState IS NULL')
+                    ->getQuery()->getResult();
+                    
+            $qb = $em->getRepository($class)->createQueryBuilder($class);
+            $result = $qb->update($class, 'o')
+                ->set('o.workflow', ':workflow')
+                ->setParameter('workflow', $workflow)
+                ->getQuery()->getResult();
             
             $output->writeln("<info>Se ejecutó la actualización de entidates</info> {$class}");
             $output->writeln("<info>Result:</info> {$result}");