From ce79874cd32864345a6a40bea645b51b064da138 Mon Sep 17 00:00:00 2001 From: Bruno Menezes Date: Mon, 9 Jun 2014 14:24:21 -0300 Subject: [PATCH] correção edição de módulos AcaoSo --- src/Cacic/CommonBundle/Entity/AcaoSoRepository.php | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/Cacic/CommonBundle/Entity/AcaoSoRepository.php b/src/Cacic/CommonBundle/Entity/AcaoSoRepository.php index 8ddf7df..0b66c4e 100644 --- a/src/Cacic/CommonBundle/Entity/AcaoSoRepository.php +++ b/src/Cacic/CommonBundle/Entity/AcaoSoRepository.php @@ -59,19 +59,19 @@ class AcaoSoRepository extends EntityRepository */ public function atualizarPorLocal( $acao, $local, $novasRedes, $novosSO ) { - $em = $this->getEntityManager(); - $redesLocal = $em->getRepository( 'CacicCommonBundle:Rede' )->getArrayChaveValorPorLocal( $local ); - - foreach ( $redesLocal as $idRede => $nmRede ) - { - $arr = $this->findBy( array( 'acao'=>$acao, 'rede'=>$idRede ) ); - foreach ( $arr as $obj ) - $em->remove( $obj ); - } - - $em->flush(); - - foreach( $novasRedes as $rede ) + + $em = $this->getEntityManager(); + + $apagaObj = $em->getRepository( 'CacicCommonBundle:AcaoSo' )->findAll(); + + foreach ( $apagaObj as $acaoObj){ + if (!empty($acaoObj)) + $em->remove($acaoObj); + } + + $em->flush(); + + foreach( $novasRedes as $rede ) { foreach ( $novosSO as $so ) { @@ -82,7 +82,8 @@ class AcaoSoRepository extends EntityRepository $em->persist( $new ); } } - - $em->flush(); + + $em->flush(); + } } \ No newline at end of file -- libgit2 0.21.2