|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Decline\TransformatBundle\Command; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
|
6
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
8
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
9
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class FormatCommand |
|
13
|
|
|
* @package Decline\TransformatBundle\Command |
|
14
|
|
|
*/ |
|
15
|
|
|
class FormatCommand extends ContainerAwareCommand |
|
16
|
|
|
{ |
|
17
|
|
|
|
|
18
|
|
|
const ARGUMENT_FILENAME = 'filename'; |
|
19
|
|
|
|
|
20
|
|
|
const COMMAND_NAME = 'transformat:format'; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Configuration for the FormatCommand |
|
24
|
|
|
*/ |
|
25
|
5 |
|
protected function configure() |
|
26
|
|
|
{ |
|
27
|
|
|
$this |
|
28
|
5 |
|
->addArgument( |
|
29
|
5 |
|
static::ARGUMENT_FILENAME, |
|
30
|
5 |
|
InputArgument::OPTIONAL, |
|
31
|
5 |
|
'A single filename in the configured directory.' |
|
32
|
|
|
) |
|
33
|
5 |
|
->setName(static::COMMAND_NAME) |
|
34
|
5 |
|
->setDescription('Format translation files.') |
|
35
|
5 |
|
->setHelp('Formats the configured set of translation files and performs some validity checks.'); |
|
36
|
5 |
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* |
|
40
|
|
|
* @param InputInterface $input |
|
41
|
|
|
* @param OutputInterface $output |
|
42
|
|
|
* @return int|null|void |
|
43
|
|
|
*/ |
|
44
|
5 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
45
|
|
|
{ |
|
46
|
5 |
|
$io = new SymfonyStyle($input, $output); |
|
47
|
5 |
|
$io->title('Decline Transformat Bundle'); |
|
48
|
|
|
|
|
49
|
5 |
|
$io->text('Starting to format translation files:'); |
|
50
|
|
|
|
|
51
|
5 |
|
$errors = $this->getContainer()->get('decline_transformat.format')->format( |
|
52
|
|
|
$io, |
|
53
|
5 |
|
$input->getArgument(static::ARGUMENT_FILENAME) |
|
54
|
|
|
); |
|
55
|
|
|
|
|
56
|
5 |
|
$io->newLine(); |
|
57
|
|
|
|
|
58
|
5 |
|
if (count($errors)) { |
|
59
|
4 |
|
$io->error($errors); |
|
60
|
|
|
} else { |
|
61
|
1 |
|
$io->success('Done.'); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
} |