GearmanJobDescribeCommand.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * Gearman Bundle for Symfony2
  4. *
  5. * @author Marc Morera <yuhu@mmoreram.com>
  6. * @since 2013
  7. */
  8. namespace Mmoreram\GearmanBundle\Command;
  9. use Symfony\Component\Console\Input\InputArgument;
  10. use Symfony\Component\Console\Input\InputInterface;
  11. use Symfony\Component\Console\Output\OutputInterface;
  12. use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
  13. /**
  14. * Gearman Job Describe Command class
  15. *
  16. * @author Marc Morera <yuhu@mmoreram.com>
  17. */
  18. class GearmanJobDescribeCommand extends ContainerAwareCommand
  19. {
  20. /**
  21. * Console Command configuration
  22. */
  23. protected function configure()
  24. {
  25. parent::configure();
  26. $this
  27. ->setName('gearman:job:describe')
  28. ->setDescription('Describe given job')
  29. ->addArgument('job', InputArgument::REQUIRED, 'job to describe');
  30. }
  31. /**
  32. * Executes the current command.
  33. *
  34. * @param InputInterface $input An InputInterface instance
  35. * @param OutputInterface $output An OutputInterface instance
  36. *
  37. * @return integer 0 if everything went fine, or an error code
  38. *
  39. * @throws \LogicException When this abstract class is not implemented
  40. */
  41. protected function execute(InputInterface $input, OutputInterface $output)
  42. {
  43. $job = $input->getArgument('job');
  44. $job = $this->getContainer()->get('gearman')->getJob($job);
  45. $this
  46. ->getContainer()
  47. ->get('gearman.describer')
  48. ->describeJob($output, $job);
  49. }
  50. }