setName('workflow:run:action') ->setDescription('Ejecuta un Action de workflow para una Entidad') ->setHelp('Ejecuta un Action (WorflowBundle\Entity\Action) de workflow para una Entidad (WorkflowBundle\Utils\WorkFlowEntityClasses)') ->addOption( 'action', null, InputOption::VALUE_REQUIRED, 'Action name' ) ->addOption( 'entity', null, InputOption::VALUE_REQUIRED, 'Entity Class. Possible values: ' . implode(', ', WorkFlowEntityClasses::getConstants()) ) ->addOption( 'id', null, InputOption::VALUE_REQUIRED, 'Entity id' ) ; } /** * @param InputInterface $input * @param OutputInterface $output */ protected function execute(InputInterface $input, OutputInterface $output) { /* @var $producerService \WorkflowBundle\Services\ProducerService */ $producerService = $this->getContainer()->get("workflow.producer_service"); $actionName = $input->getOption('action'); $entityClass = $input->getOption('entity'); $entityId = $input->getOption('id'); if ($actionName && $entityClass && $entityId) { $producerService->executeAction($actionName, $entityClass, $entityId); $output->writeln("Action '{$actionName}' para la entidad '{$entityClass}' ejecutada"); } else { $output->writeln('Ingrese todas las opciones'); } } }