Commit 7c8c12a8603edc394825bbb6a69a801db7d3889b
1 parent
d9059f70
Exists in
master
and in
1 other branch
Desabilita por padrão a coleta de patrimônio em todos os módulos
Showing
1 changed file
with
47 additions
and
0 deletions
Show diff stats
src/Cacic/CommonBundle/DoctrineMigrations/Version20140528153001.php
0 → 100644
| ... | ... | @@ -0,0 +1,47 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace Cacic\CommonBundle\Migrations; | |
| 4 | + | |
| 5 | +use Symfony\Component\DependencyInjection\ContainerAwareInterface; | |
| 6 | +use Symfony\Component\DependencyInjection\ContainerInterface; | |
| 7 | +use Doctrine\DBAL\Migrations\AbstractMigration; | |
| 8 | +use Doctrine\DBAL\Schema\Schema; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * Auto-generated Migration: Please modify to your needs! | |
| 12 | + */ | |
| 13 | +class Version20140528153001 extends AbstractMigration implements ContainerAwareInterface | |
| 14 | +{ | |
| 15 | + private $container; | |
| 16 | + | |
| 17 | + public function setContainer(ContainerInterface $container = null) | |
| 18 | + { | |
| 19 | + $this->container = $container; | |
| 20 | + } | |
| 21 | + | |
| 22 | + public function up(Schema $schema) | |
| 23 | + { | |
| 24 | + // this up() migration is auto-generated, please modify it to your needs | |
| 25 | + $em = $this->container->get('doctrine.orm.entity_manager'); | |
| 26 | + $logger = $this->container->get('logger'); | |
| 27 | + $modulos = $em->getRepository('CacicCommonBundle:Acao')->findBy( array('csOpcional' => 'N') ); | |
| 28 | + | |
| 29 | + foreach ($modulos as $elm) { | |
| 30 | + // PEga todos os módulos que são opcionais e remove da tabela acao_rede | |
| 31 | + $acoes = $em->getRepository('CacicCommonBundle:AcaoRede')->findBy( array('acao' => $elm->getIdAcao() ) ); | |
| 32 | + | |
| 33 | + foreach ($acoes as $acao) { | |
| 34 | + $em->remove($acao); | |
| 35 | + } | |
| 36 | + } | |
| 37 | + | |
| 38 | + $em->flush(); | |
| 39 | + | |
| 40 | + } | |
| 41 | + | |
| 42 | + public function down(Schema $schema) | |
| 43 | + { | |
| 44 | + // this down() migration is auto-generated, please modify it to your needs | |
| 45 | + | |
| 46 | + } | |
| 47 | +} | |
| 0 | 48 | \ No newline at end of file | ... | ... |