FlushCommand::execute()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 9.4285
cc 3
eloc 9
nc 3
nop 2
1
<?php
2
3
namespace N98\Magento\Command\Cache;
4
5
use N98\Magento\Application;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
class FlushCommand extends AbstractModifierCommand
10
{
11
    protected function configure()
12
    {
13
        $this
14
            ->setName('cache:flush')
15
            ->setDescription('Flush magento cache storage')
16
        ;
17
    }
18
19
    /**
20
     * @param \Symfony\Component\Console\Input\InputInterface $input
21
     * @param \Symfony\Component\Console\Output\OutputInterface $output
22
     * @return int|void
23
     */
24
    protected function execute(InputInterface $input, OutputInterface $output)
25
    {
26
        $this->detectMagento($output, true);
27
        if (!$this->initMagento()) {
28
            return;
29
        }
30
31
        $cacheManager = $this->getCacheManager();
32
33
        $availableTypes = $cacheManager->getAvailableTypes();
34
        foreach ($availableTypes as $cacheType) {
35
            $cacheManager->flush(array($cacheType));
36
            $output->writeln('<info><comment>' . $cacheType . '</comment> cache flushed</info>');
37
        }
38
    }
39
}
40