| Conditions | 3 |
| Paths | 3 |
| Total Lines | 24 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 27 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 28 | { |
||
| 29 | $env = $this->getContainer()->getParameter('kernel.environment'); |
||
| 30 | $output->writeLn("Clearing app cache for environment <comment>{$env}</comment>..."); |
||
| 31 | |||
| 32 | $cache = $this->getContainer()->get('cache.default'); |
||
| 33 | if ($cache instanceof RedisCache) { |
||
| 34 | if ($env === 'test') { |
||
| 35 | $cache->flushDB(); |
||
| 36 | $output->writeln('Flushed all redis cache'); |
||
| 37 | } else { |
||
| 38 | // flush only namespaced keys for redis cache |
||
| 39 | $output->writeLn(sprintf( |
||
| 40 | "Flushed <comment>%s</comment> cache entries", |
||
| 41 | trim($cache->flushNamespacedKeys()) |
||
| 42 | )); |
||
| 43 | } |
||
| 44 | } else { |
||
| 45 | // do not mind and remove all cache (array cache) |
||
| 46 | $cache->flushAll(); |
||
| 47 | } |
||
| 48 | |||
| 49 | $output->writeLn("Cache was cleared."); |
||
| 50 | } |
||
| 51 | } |
||
| 52 |