Commit 08ee596bdd3a0624eeee9c23943efa092536511c
1 parent
505228f2
Exists in
master
and in
1 other branch
Marca e desmarca subredes apra executar os módulos
Showing
1 changed file
with
21 additions
and
18 deletions
Show diff stats
src/Cacic/CommonBundle/Entity/AcaoRedeRepository.php
... | ... | @@ -50,28 +50,31 @@ class AcaoRedeRepository extends EntityRepository |
50 | 50 | */ |
51 | 51 | public function atualizarPorLocal( $acao, $local, $novasRedes ) |
52 | 52 | { |
53 | - $em = $this->getEntityManager(); | |
54 | - $redesLocal = $em->getRepository( 'CacicCommonBundle:Rede' )->getArrayChaveValorPorLocal( $local ); | |
53 | + $em = $this->getEntityManager(); | |
55 | 54 | |
56 | - foreach ( $redesLocal as $idRede => $nmRede ) | |
57 | - { | |
58 | - $arr = $this->findBy( array( 'acao'=>$acao, 'rede'=>$idRede ) ); | |
59 | - foreach ( $arr as $obj ) | |
60 | - $em->remove( $obj ); | |
61 | - } | |
62 | - | |
63 | - $em->flush(); | |
64 | - | |
65 | - foreach ( $novasRedes as $rede ) | |
55 | + $apagaObj = $em->getRepository( 'CacicCommonBundle:AcaoRede' )->findBy( array( 'acao'=>$acao ) ); | |
56 | + | |
57 | + foreach ( $apagaObj as $acao){ | |
58 | + if (!empty($acao)) | |
59 | + $em->remove($acao); | |
60 | + } | |
61 | + | |
62 | + $em->flush(); | |
63 | + | |
64 | + foreach ( $novasRedes as $idRede ) | |
66 | 65 | { |
67 | - $new = new AcaoRede(); | |
68 | - $new->setAcao( $em->getRepository( 'CacicCommonBundle:Acao' )->find( $acao ) ); | |
69 | - $new->setRede( $em->getRepository( 'CacicCommonBundle:Rede' )->find( $rede ) ); | |
70 | - $em->persist( $new ); | |
66 | + // $log = implode(",", $novasRedes); | |
67 | + | |
68 | + $new = new AcaoRede(); | |
69 | + $new->setAcao( $em->getRepository( 'CacicCommonBundle:Acao' )->find( $acao ) ); | |
70 | + $new->setRede( $em->getRepository( 'CacicCommonBundle:Rede' )->find( $idRede ) ); | |
71 | + $em->persist( $new ); | |
72 | + | |
71 | 73 | } |
72 | - | |
74 | + | |
73 | 75 | $em->flush(); |
74 | - } | |
76 | + | |
77 | + } | |
75 | 78 | |
76 | 79 | /** |
77 | 80 | * Habilita todas as ações para a Rede fornecida ou conjunto de redes fornecidas | ... | ... |