setName('workflow:generate:list') // the short description shown while running "php bin/console list" ->setDescription('Genera el contenido para el archivo workflow_list.yml.') // the full command description shown when running the command with // the "--help" option ->setHelp('Genera el contenido para el archivo workflow_list.yml.') ; } protected function execute(InputInterface $input, OutputInterface $output) { // Init $em = $this->getContainer()->get("doctrine.orm.entity_manager"); $workflows = $em->getRepository("WorkflowBundle:Workflow")->findBy(array('enable'=>1)); $rootDir = $this->getContainer()->getParameter('kernel.root_dir'); $workflow_template = array(); $workflow_template['framework'] = array(); $templates = array(); foreach($workflows as $k => $workflow) { $body = array(); $body['type'] = $workflow->getType(); if(is_array($workflow->getMarkingName())) { $markingName = $workflow->getMarkingName(); } else { $markingName = array(0 => $workflow->getMarkingName()); } $body['marking_store'] = array('type' => $workflow->getMarkingType(), 'arguments' => $markingName); $body['supports'] = $workflow->getSupport(); $body += Yaml::parse($workflow->getTemplate()); $templates[$workflow->getName()] = $body; } $workflow_file = $rootDir."/Resources/workflows/workflow_list.yml"; $handle = fopen($workflow_file,"w+"); if($templates) { $workflow_template['framework'] = array('workflows' => $templates); $yaml = Yaml::dump($workflow_template,100,2); fwrite($handle,$yaml); } else { fwrite($handle,""); } fclose($handle); chmod($workflow_file, 0777); } }