PageRenderTime 44ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/doctrine/doctrine-cache-bundle/Doctrine/Bundle/DoctrineCacheBundle/Command/FlushCommand.php

https://gitlab.com/ineszribi/SmartBookStoreWeb
PHP | 43 lines | 26 code | 6 blank | 11 comment | 1 complexity | f90da5b401a43820365a91fc0e859cdb MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. namespace Doctrine\Bundle\DoctrineCacheBundle\Command;
  3. use Symfony\Component\Console\Input\InputArgument;
  4. use Symfony\Component\Console\Input\InputInterface;
  5. use Symfony\Component\Console\Output\OutputInterface;
  6. /**
  7. * Flush a cache provider.
  8. *
  9. * @author Alan Doucette <dragonwize@gmail.com>
  10. */
  11. class FlushCommand extends CacheCommand
  12. {
  13. /**
  14. * {@inheritdoc}
  15. */
  16. protected function configure()
  17. {
  18. $this->setName('doctrine:cache:flush')
  19. ->setAliases(array('doctrine:cache:clear'))
  20. ->setDescription('Flush a given cache')
  21. ->addArgument('cache-name', InputArgument::REQUIRED, 'Which cache provider to flush?');
  22. }
  23. /**
  24. * {@inheritdoc}
  25. */
  26. protected function execute(InputInterface $input, OutputInterface $output)
  27. {
  28. $cacheName = $input->getArgument('cache-name');
  29. $cacheProvider = $this->getCacheProvider($cacheName);
  30. if ( ! method_exists($cacheProvider, 'flushAll')) {
  31. throw new \RuntimeException('Cache provider does not implement a flushAll method.');
  32. }
  33. $cacheProviderName = get_class($cacheProvider);
  34. $output->writeln(sprintf('Clearing the cache for the <info>%s</info> provider of type <info>%s</info>', $cacheName, $cacheProviderName, true));
  35. $cacheProvider->flushAll();
  36. }
  37. }