ClearQueryCacheDoctrineCommand.php 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Bundle\DoctrineBundle\Command\Proxy;
  11. use Symfony\Component\Console\Input\InputOption;
  12. use Symfony\Component\Console\Input\InputInterface;
  13. use Symfony\Component\Console\Output\OutputInterface;
  14. use Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand;
  15. /**
  16. * Command to clear the query cache of the various cache drivers.
  17. *
  18. * @author Fabien Potencier <fabien@symfony.com>
  19. * @author Jonathan H. Wage <jonwage@gmail.com>
  20. */
  21. class ClearQueryCacheDoctrineCommand extends QueryCommand
  22. {
  23. protected function configure()
  24. {
  25. parent::configure();
  26. $this
  27. ->setName('doctrine:cache:clear-query')
  28. ->setDescription('Clears all query cache for a entity manager')
  29. ->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command')
  30. ->setHelp(<<<EOT
  31. The <info>doctrine:cache:clear-query</info> command clears all query cache for
  32. the default entity manager:
  33. <info>php app/console doctrine:cache:clear-query</info>
  34. You can also optionally specify the <comment>--em</comment> option to specify
  35. which entity manager to clear the cache for:
  36. <info>php app/console doctrine:cache:clear-query --em=default</info>
  37. EOT
  38. );
  39. }
  40. protected function execute(InputInterface $input, OutputInterface $output)
  41. {
  42. DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
  43. return parent::execute($input, $output);
  44. }
  45. }