GearmanWorkerDescribeCommand.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 GearmanWorkerDescribeCommand extends ContainerAwareCommand
  19. {
  20. /**
  21. * Console Command configuration
  22. */
  23. protected function configure()
  24. {
  25. parent::configure();
  26. $this->setName('gearman:worker:describe')
  27. ->setDescription('Describe given worker')
  28. ->addArgument('worker', InputArgument::REQUIRED, 'worker to describe');
  29. }
  30. /**
  31. * Executes the current command.
  32. *
  33. * @param InputInterface $input An InputInterface instance
  34. * @param OutputInterface $output An OutputInterface instance
  35. *
  36. * @return integer 0 if everything went fine, or an error code
  37. *
  38. * @throws \LogicException When this abstract class is not implemented
  39. */
  40. protected function execute(InputInterface $input, OutputInterface $output)
  41. {
  42. $worker = $input->getArgument('worker');
  43. $worker = $this->getContainer()->get('gearman')->getWorker($worker);
  44. $this->getContainer()->get('gearman.describer')->describeWorker($output, $worker);
  45. }
  46. }