Commit ce79874cd32864345a6a40bea645b51b064da138

Authored by Bruno Menezes
1 parent 56503325
Exists in master and in 1 other branch 3.1

correção edição de módulos AcaoSo

src/Cacic/CommonBundle/Entity/AcaoSoRepository.php
... ... @@ -59,19 +59,19 @@ class AcaoSoRepository extends EntityRepository
59 59 */
60 60 public function atualizarPorLocal( $acao, $local, $novasRedes, $novosSO )
61 61 {
62   - $em = $this->getEntityManager();
63   - $redesLocal = $em->getRepository( 'CacicCommonBundle:Rede' )->getArrayChaveValorPorLocal( $local );
64   -
65   - foreach ( $redesLocal as $idRede => $nmRede )
66   - {
67   - $arr = $this->findBy( array( 'acao'=>$acao, 'rede'=>$idRede ) );
68   - foreach ( $arr as $obj )
69   - $em->remove( $obj );
70   - }
71   -
72   - $em->flush();
73   -
74   - foreach( $novasRedes as $rede )
  62 +
  63 + $em = $this->getEntityManager();
  64 +
  65 + $apagaObj = $em->getRepository( 'CacicCommonBundle:AcaoSo' )->findAll();
  66 +
  67 + foreach ( $apagaObj as $acaoObj){
  68 + if (!empty($acaoObj))
  69 + $em->remove($acaoObj);
  70 + }
  71 +
  72 + $em->flush();
  73 +
  74 + foreach( $novasRedes as $rede )
75 75 {
76 76 foreach ( $novosSO as $so )
77 77 {
... ... @@ -82,7 +82,8 @@ class AcaoSoRepository extends EntityRepository
82 82 $em->persist( $new );
83 83 }
84 84 }
85   -
86   - $em->flush();
  85 +
  86 + $em->flush();
  87 +
87 88 }
88 89 }
89 90 \ No newline at end of file
... ...