ClearCacheCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 3 1
A getManagedLocales() 0 3 1
A execute() 0 5 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
     * @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
27
     */
28
    public function execute(InputInterface $input, OutputInterface $output)
29
    {
30
        $locales = $this->getManagedLocales();
31
        $output->writeln('Remove cache for translations in: '.implode(', ', $locales));
32
        $this->getContainer()->get('translator')->removeLocalesCacheFiles($locales);
33
    }
34
35
    /**
36
     * @return array
37
     * @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
38
     * @throws \LogicException
39
     */
40
    protected function getManagedLocales()
41
    {
42
        return $this->getContainer()->getParameter('lexik_translation.managed_locales');
43
    }
44
}
45