811a6bf5eb
* 3.2: [Bridge\Doctrine] Fix change breaking doctrine-bundle test suite [WebProfilerBundle] Include badge status in translation tabs [FrameworkBundle] Cache pool clear command requires at least 1 pool [HttpFoundation][bugfix] should always be initialized MockArraySessionStorage: updated phpdoc for $bags so that IDE autocompletion would work normalize paths before making them relative removed test that does not test anything fixed tests #21809 [SecurityBundle] bugfix: if security provider's name contains upper cases then container didn't compile [WebProfilerBundle] Fix for CSS attribute at Profiler Translation Page Set Date header in Response constructor already [Validator] fix URL validator to detect non supported chars according to RFC 3986 [Security] Fixed roles serialization on token from user object
94 lines
2.9 KiB
PHP
94 lines
2.9 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Symfony\Bundle\FrameworkBundle\Command;
|
|
|
|
use Psr\Cache\CacheItemPoolInterface;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
|
use Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer;
|
|
|
|
/**
|
|
* Clear cache pools.
|
|
*
|
|
* @author Nicolas Grekas <p@tchwork.com>
|
|
*/
|
|
final class CachePoolClearCommand extends ContainerAwareCommand
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function configure()
|
|
{
|
|
$this
|
|
->setName('cache:pool:clear')
|
|
->setDefinition(array(
|
|
new InputArgument('pools', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'A list of cache pools or cache pool clearers'),
|
|
))
|
|
->setDescription('Clears cache pools')
|
|
->setHelp(<<<'EOF'
|
|
The <info>%command.name%</info> command clears the given cache pools or cache pool clearers.
|
|
|
|
%command.full_name% <cache pool or clearer 1> [...<cache pool or clearer N>]
|
|
EOF
|
|
)
|
|
;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
{
|
|
$io = new SymfonyStyle($input, $output);
|
|
$pools = array();
|
|
$clearers = array();
|
|
$container = $this->getContainer();
|
|
$cacheDir = $container->getParameter('kernel.cache_dir');
|
|
$globalClearer = $container->get('cache.global_clearer');
|
|
|
|
foreach ($input->getArgument('pools') as $id) {
|
|
if ($globalClearer->hasPool($id)) {
|
|
$pools[$id] = $id;
|
|
} else {
|
|
$pool = $container->get($id);
|
|
|
|
if ($pool instanceof CacheItemPoolInterface) {
|
|
$pools[$id] = $pool;
|
|
} elseif ($pool instanceof Psr6CacheClearer) {
|
|
$clearers[$id] = $pool;
|
|
} else {
|
|
throw new \InvalidArgumentException(sprintf('"%s" is not a cache pool nor a cache clearer.', $id));
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach ($clearers as $id => $clearer) {
|
|
$io->comment(sprintf('Calling cache clearer: <info>%s</info>', $id));
|
|
$clearer->clear($cacheDir);
|
|
}
|
|
|
|
foreach ($pools as $id => $pool) {
|
|
$io->comment(sprintf('Clearing cache pool: <info>%s</info>', $id));
|
|
|
|
if ($pool instanceof CacheItemPoolInterface) {
|
|
$pool->clear();
|
|
} else {
|
|
$globalClearer->clearPool($id);
|
|
}
|
|
}
|
|
|
|
$io->success('Cache was successfully cleared.');
|
|
}
|
|
}
|