GearmanJobDescribeCommand.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Mmoreram\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 Job Describe Command class
  11. *
  12. * @author Marc Morera <yuhu@mmoreram.com>
  13. */
  14. class GearmanJobDescribeCommand extends ContainerAwareCommand
  15. {
  16. /**
  17. * Console Command configuration
  18. */
  19. protected function configure()
  20. {
  21. parent::configure();
  22. $this->setName('gearman:job:describe')
  23. ->setDescription('Describe given job')
  24. ->addArgument('job', InputArgument::REQUIRED, 'job to describe');
  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. $job = $this->getContainer()->get('gearman')->getJob($job);
  40. $this
  41. ->getContainer()
  42. ->get('gearman.describer')
  43. ->describeJob($output, $job);
  44. }
  45. }