Completed
Push — master ( d7e919...298f7d )
by Simonas
64:16
created

ExportCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 17
ccs 14
cts 14
cp 1
rs 9.4285
cc 1
eloc 13
nc 1
nop 0
crap 1
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\TranslationsBundle\Command;
13
14
use ONGR\TranslationsBundle\Service\Export\ExportManager;
15
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Input\InputOption;
18
use Symfony\Component\Console\Output\OutputInterface;
19
20
/**
21
 * Exports translations.
22
 */
23
class ExportCommand extends ContainerAwareCommand
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28 4
    protected function configure()
29
    {
30 4
        $this->setName('ongr:translations:export');
31 4
        $this->setDescription('Export all translations from ES to yaml.');
32 4
        $this->addOption(
33 4
            'locales',
34 4
            'l',
35 4
            InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
36 4
            'Export only these locales, instead of using the managed locales.'
37
        );
38 4
        $this->addOption(
39 4
            'force',
40 4
            'f',
41 4
            InputOption::VALUE_NONE,
42 4
            'If set, the bundle will export all translations, regardless of status'
43 4
        );
44
    }
45 4
46
    /**
47
     * {@inheritdoc}
48
     */
49
    protected function execute(InputInterface $input, OutputInterface $output)
50 4
    {
51
        /** @var ExportManager $export */
52
        $export = $this->getContainer()->get('ongr_translations.export');
53 4
54
        $locales = $input->getOption('locales');
55 4
        if (!empty($locales)) {
56 4
            $export->setManagedLocales($locales);
0 ignored issues
show
Bug introduced by
The method setManagedLocales() does not seem to exist on object<ONGR\Translations...e\Export\ExportManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
57 1
        }
58
59
        $domains = $input->getOption('domains');
60 4
        $export->export($domains, $input->getOption('force'));
61 4
62
        $prettify = function ($array) {
63
            return !empty($array) ? implode('</comment><info>`, `</info><comment>', $array) : 'all';
64
        };
65
66
        $output->writeln(
67
            sprintf(
68
                '<info>Successfully exported translations in `</info>'
69
                . '<comment>%s</comment><info>` locale(s) for `</info>'
70
                . '<comment>%s</comment><info>` domain(s).</info>',
71
                $prettify($locales),
72
                $prettify($domains)
73
            )
74
        );
75
    }
76
}
77