Completed
Pull Request — 1.0 (#644)
by
unknown
03:06
created

CacheClearCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[email protected]>
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 ONGR\ElasticsearchBundle\Command;
13
14
use Symfony\Component\Console\Input\InputInterface;
15
use Symfony\Component\Console\Output\OutputInterface;
16
use Symfony\Component\Console\Style\SymfonyStyle;
17
18
/**
19
 * Symfony command for clearing elasticsearch cache.
20
 */
21
class CacheClearCommand extends AbstractManagerAwareCommand
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    protected function configure()
27
    {
28
        parent::configure();
29
30
        $this
31
            ->setName('ongr:es:cache:clear')
32
            ->setDescription('Clears elasticsearch client cache.');
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    protected function execute(InputInterface $input, OutputInterface $output)
39
    {
40
        $io = new SymfonyStyle($input, $output);
41
        $this
42
            ->getManager($input->getOption('manager'))
43
            ->clearCache();
44
        $io->success(
45
            sprintf(
46
                'Elasticsearch index cache has been cleared for manager named `%s`',
47
                $input->getOption('manager')
48
            )
49
        );
50
    }
51
}
52