vendor/symfony/src/Symfony/Bundle/DoctrineBundle/Command/Proxy/ClearResultCacheDoctrineCommand.php
changeset 0 7f95f8617b0b
equal deleted inserted replaced
-1:000000000000 0:7f95f8617b0b
       
     1 <?php
       
     2 
       
     3 /*
       
     4  * This file is part of the Symfony package.
       
     5  *
       
     6  * (c) Fabien Potencier <fabien@symfony.com>
       
     7  *
       
     8  * For the full copyright and license information, please view the LICENSE
       
     9  * file that was distributed with this source code.
       
    10  */
       
    11 
       
    12 namespace Symfony\Bundle\DoctrineBundle\Command\Proxy;
       
    13 
       
    14 use Symfony\Component\Console\Input\InputOption;
       
    15 use Symfony\Component\Console\Input\InputInterface;
       
    16 use Symfony\Component\Console\Output\OutputInterface;
       
    17 use Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand;
       
    18 
       
    19 /**
       
    20  * Command to clear the result cache of the various cache drivers.
       
    21  *
       
    22  * @author Fabien Potencier <fabien@symfony.com>
       
    23  * @author Jonathan H. Wage <jonwage@gmail.com>
       
    24  */
       
    25 class ClearResultCacheDoctrineCommand extends ResultCommand
       
    26 {
       
    27     protected function configure()
       
    28     {
       
    29         parent::configure();
       
    30 
       
    31         $this
       
    32             ->setName('doctrine:cache:clear-result')
       
    33             ->setDescription('Clear result cache for a entity manager')
       
    34             ->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command')
       
    35             ->setHelp(<<<EOT
       
    36 The <info>doctrine:cache:clear-result</info> command clears all result cache
       
    37 for the default entity manager:
       
    38 
       
    39 <info>php app/console doctrine:cache:clear-result</info>
       
    40 
       
    41 You can also optionally specify the <comment>--em</comment> option to specify
       
    42 which entity manager to clear the cache for:
       
    43 
       
    44 <info>php app/console doctrine:cache:clear-result --em=default</info>
       
    45 
       
    46 If you don't want to clear all result cache you can specify some additional
       
    47 options to control what cache is deleted:
       
    48 
       
    49 <info>php app/console doctrine:cache:clear-result --id=cache_key</info>
       
    50 
       
    51 Or you can specify a <comment>--regex</comment> to delete cache entries that
       
    52 match it:
       
    53 
       
    54 <info>php app/console doctrine:cache:clear-result --regex="user_(.*)"</info>
       
    55 
       
    56 You can also specify a <comment>--prefix</comment> or
       
    57 <comment>--suffix</comment> to delete cache entries for:
       
    58 
       
    59 <info>php app/console doctrine:cache:clear-result --prefix="user_" --suffix="_frontend"</info>
       
    60 EOT
       
    61         );
       
    62     }
       
    63 
       
    64     protected function execute(InputInterface $input, OutputInterface $output)
       
    65     {
       
    66         DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
       
    67 
       
    68         return parent::execute($input, $output);
       
    69     }
       
    70 }