GearmanCacheClearCommand.php 1.4 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. * Warm ups 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 ->setName('gearman:cache:clear')
  26. ->setAliases(array('cache:gearman:clear'))
  27. ->setDescription('Clears gearman cache data on current environment');
  28. }
  29. /**
  30. * Executes the current command.
  31. *
  32. * @param InputInterface $input An InputInterface instance
  33. * @param OutputInterface $output An OutputInterface instance
  34. *
  35. * @return integer 0 if everything went fine, or an error code
  36. *
  37. * @throws \LogicException When this abstract class is not implemented
  38. */
  39. protected function execute(InputInterface $input, OutputInterface $output)
  40. {
  41. $output->writeln('Clearing the cache for the ' . $this->getContainer()->get('kernel')->getEnvironment() . ' environment');
  42. $this
  43. ->getContainer()
  44. ->get('gearman.cache.wrapper')
  45. ->flush();
  46. }
  47. }