12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace WorkflowBundle\Command;
- use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
- use Symfony\Component\Console\Input\InputInterface;
- use Symfony\Component\Console\Input\InputOption;
- use Symfony\Component\Console\Output\OutputInterface;
- use WorkflowBundle\Utils\WorkFlowEntityClasses;
- class WorkflowRunActionCommand extends ContainerAwareCommand
- {
- protected function configure()
- {
- $this
- ->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("<info>Action '{$actionName}' para la entidad '{$entityClass}' ejecutada</info>");
- } else {
- $output->writeln('<error>Ingrese todas las opciones</error>');
- }
- }
- }
|