ClearCacheCommand::getManagedLocales()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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