Passed
Push — master ( c9bd7c...617e81 )
by Dāvis
02:28
created

ClearCacheCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 26
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 3 1
A execute() 0 5 1
A getManagedLocales() 0 3 1
1
<?php
2
3
namespace Sludio\HelperBundle\Lexik\Command;
4
5
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
/**
10
 * Class ClearCacheCommand
11
 *
12
 * @package Sludio\HelperBundle\Lexik\Command
13
 */
14
class ClearCacheCommand extends ContainerAwareCommand
15
{
16
    public function configure()
17
    {
18
        $this->setName('sludio:lexik:clear');;
19
    }
20
21
    /**
22
     * @param InputInterface  $input
23
     * @param OutputInterface $output
24
     *
25
     * @return int|null|void
26
     */
27
    public function execute(InputInterface $input, OutputInterface $output)
28
    {
29
        $locales = $this->getManagedLocales();
30
        $output->writeln('Remove cache for translations in: '.implode(", ", $locales));
31
        $this->getContainer()->get('translator')->removeLocalesCacheFiles($locales);
32
    }
33
34
    /**
35
     * @return array
36
     */
37
    protected function getManagedLocales()
38
    {
39
        return $this->getContainer()->getParameter('lexik_translation.managed_locales');
40
    }
41
}