GearmanWorkerDescribeCommand.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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
  27. ->setName('gearman:worker:describe')
  28. ->setDescription('Describe given worker')
  29. ->addArgument('worker', InputArgument::REQUIRED, 'worker 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. $worker = $input->getArgument('worker');
  44. $worker = $this->getContainer()->get('gearman')->getWorker($worker);
  45. $this->getContainer()->get('gearman.describer')->describeWorker($output, $worker);
  46. }
  47. }