GearmanClientExecuteCommand.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace Mmoreramerino\GearmanBundle\Command;
  3. use Symfony\Component\Console\Input\InputOption;
  4. use Symfony\Component\Console\Input\InputArgument;
  5. use Symfony\Component\Console\Input\InputInterface;
  6. use Symfony\Component\Console\Input\InputDefinition;
  7. use Symfony\Component\Console\Output\OutputInterface;
  8. use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
  9. /**
  10. * Gearman Client Execute Command class
  11. *
  12. * @author Marc Morera <marc@ulabox.com>
  13. */
  14. class GearmanClientExecuteCommand extends ContainerAwareCommand
  15. {
  16. /**
  17. * Console Command configuration
  18. */
  19. protected function configure()
  20. {
  21. parent::configure();
  22. $this->setName('gearman:client:execute')
  23. ->setDescription('Test')
  24. ->addArgument('job', InputArgument::REQUIRED, 'job to execute');
  25. }
  26. /**
  27. * Executes the current command.
  28. *
  29. * @param InputInterface $input An InputInterface instance
  30. * @param OutputInterface $output An OutputInterface instance
  31. *
  32. * @return integer 0 if everything went fine, or an error code
  33. *
  34. * @throws \LogicException When this abstract class is not implemented
  35. */
  36. protected function execute(InputInterface $input, OutputInterface $output)
  37. {
  38. $job = $input->getArgument('job');
  39. $this->getContainer()->get('gearman')->callJob($job);
  40. }
  41. }