GearmanCacheClearCommand.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\InputInterface;
  10. use Symfony\Component\Console\Output\OutputInterface;
  11. use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
  12. /**
  13. * Clears all cache data
  14. *
  15. * @author Marc Morera <yuhu@mmoreram.com>
  16. */
  17. class GearmanCacheClearCommand extends ContainerAwareCommand
  18. {
  19. /**
  20. * Console Command configuration
  21. */
  22. protected function configure()
  23. {
  24. parent::configure();
  25. $this
  26. ->setName('gearman:cache:clear')
  27. ->setAliases(array('cache:gearman:clear'))
  28. ->setDescription('Clears gearman cache data on current environment');
  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. $output->writeln('Clearing the cache for the ' . $this->getContainer()->get('kernel')->getEnvironment() . ' environment');
  43. /**
  44. * By requesting service, cache is loaded on the fly
  45. */
  46. $this
  47. ->getContainer()
  48. ->get('gearman.cache.wrapper');
  49. }
  50. }