Skip to content

Commit 9f1a1e2

Browse files
committed
Support "all"
1 parent 5499a62 commit 9f1a1e2

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/Command/CacheFlushCommand.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919
use Symfony\Component\Console\Input\InputArgument;
2020

2121
/**
22-
* Class CacheFlushCommand
22+
* Class CacheFlushCommand.
2323
*
2424
* @author Aaron Scherer <[email protected]>
2525
*/
2626
class CacheFlushCommand extends ContainerAwareCommand
2727
{
28-
2928
/**
3029
* {@inheritdoc}
3130
*/
@@ -41,12 +40,28 @@ protected function configure()
4140
*/
4241
protected function execute(InputInterface $input, OutputInterface $output)
4342
{
44-
$validTypes = ['session', 'routing', 'doctrine'];
43+
$validTypes = ['session', 'routing', 'doctrine', 'all'];
4544
$type = $input->getArgument('type');
4645
if (!in_array($type, $validTypes)) {
4746
$output->writeln(sprintf('Type "%s" does not exist. Valid type are: %s', $type, implode(',', $validTypes)));
4847
}
4948

49+
if ($type === 'all') {
50+
foreach (['session', 'routing', 'doctrine'] as $type) {
51+
$this->clearCacheForType($type);
52+
}
53+
} else {
54+
$this->clearCacheForType($type);
55+
}
56+
}
57+
58+
/**
59+
* Clear the cache for a type.
60+
*
61+
* @param string $type
62+
*/
63+
private function clearCacheForType($type)
64+
{
5065
$serviceId = $this->getContainer()->getParameter(sprintf('cache.%s%.service_id', $type));
5166

5267
/** @var CacheItemPoolInterface $service */

0 commit comments

Comments
 (0)