GearmanCacheClearCommand.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace Mmoreram\GearmanBundle\Command;
  3. use Symfony\Component\Console\Input\InputOption;
  4. use Symfony\Component\Console\Input\InputArgument;
  5. use Symfony\Component\Console\Input\InputInterface;
  6. use Symfony\Component\Console\Input\InputDefinition;
  7. use Mmoreram\GearmanBundle\Service\GearmanCache;
  8. use Symfony\Component\Console\Output\OutputInterface;
  9. use Mmoreram\GearmanBundle\Service\GearmanSettings;
  10. use Mmoreram\GearmanBundle\Module\GearmanBaseBundle;
  11. use Mmoreram\GearmanBundle\Service\GearmanCacheLoader;
  12. use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
  13. use Mmoreram\GearmanBundle\Exceptions\GearmanNotInstalledException;
  14. use Mmoreram\GearmanBundle\Exceptions\NoSettingsFileExistsException;
  15. /**
  16. * Warm ups all cache data
  17. *
  18. * @author Marc Morera <yuhu@mmoreram.com>
  19. */
  20. class GearmanCacheClearCommand extends ContainerAwareCommand
  21. {
  22. /**
  23. * Console Command configuration
  24. */
  25. protected function configure()
  26. {
  27. parent::configure();
  28. $this ->setName('gearman:cache:clear')
  29. ->setAliases(array('cache:gearman:clear'))
  30. ->setDescription('Clears gearman cache data on current environment');
  31. }
  32. /**
  33. * Executes the current command.
  34. *
  35. * @param InputInterface $input An InputInterface instance
  36. * @param OutputInterface $output An OutputInterface instance
  37. *
  38. * @return integer 0 if everything went fine, or an error code
  39. *
  40. * @throws \LogicException When this abstract class is not implemented
  41. */
  42. protected function execute(InputInterface $input, OutputInterface $output)
  43. {
  44. $output->writeln('Clearing the cache for the ' . $this->getContainer()->get('kernel')->getEnvironment() . ' environment');
  45. $this
  46. ->getContainer()
  47. ->get('@liip_doctrine_cache.ns.gearman')
  48. ->delete($this->getContainer()->getParameter('gearman.cache.id'));
  49. }
  50. }