1
1
<?php
2
2
3
+ declare (strict_types=1 );
4
+
3
5
/*
4
6
* Copyright 2011 Johannes M. Schmitt <[email protected] >
5
7
*
18
20
19
21
namespace JMS \TranslationBundle \Command ;
20
22
23
+ use JMS \TranslationBundle \Logger \OutputLogger ;
21
24
use JMS \TranslationBundle \Translation \ConfigBuilder ;
22
25
use JMS \TranslationBundle \Translation \ConfigFactory ;
23
26
use JMS \TranslationBundle \Translation \Updater ;
24
27
use Symfony \Component \Console \Command \Command ;
25
28
use Symfony \Component \Console \Input \InputArgument ;
26
- use JMS \TranslationBundle \Logger \OutputLogger ;
27
- use Symfony \Component \Console \Input \InputOption ;
28
29
use Symfony \Component \Console \Input \InputInterface ;
30
+ use Symfony \Component \Console \Input \InputOption ;
29
31
use Symfony \Component \Console \Output \OutputInterface ;
30
32
31
33
/**
@@ -82,14 +84,9 @@ protected function configure()
82
84
->addOption ('output-format ' , null , InputOption::VALUE_REQUIRED , 'The output format that should be used (in most cases, it is better to change only the default-output-format). ' )
83
85
->addOption ('default-output-format ' , null , InputOption::VALUE_REQUIRED , 'The default output format (defaults to xlf). ' )
84
86
->addOption ('keep ' , null , InputOption::VALUE_NONE , 'Define if the updater service should keep the old translation (defaults to false). ' )
85
- ->addOption ('external-translations-dir ' , null , InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED , 'Load external translation resources ' )
86
- ;
87
+ ->addOption ('external-translations-dir ' , null , InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED , 'Load external translation resources ' );
87
88
}
88
89
89
- /**
90
- * @param InputInterface $input
91
- * @param OutputInterface $output
92
- */
93
90
protected function execute (InputInterface $ input , OutputInterface $ output ): int
94
91
{
95
92
$ builder = $ input ->getOption ('config ' ) ?
@@ -116,7 +113,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
116
113
$ output ->writeln (sprintf ('Directories: <info>%s</info> ' , implode (', ' , $ config ->getScanDirs ())));
117
114
$ output ->writeln (sprintf ('Excluded Directories: <info>%s</info> ' , $ config ->getExcludedDirs () ? implode (', ' , $ config ->getExcludedDirs ()) : '# none # ' ));
118
115
$ output ->writeln (sprintf ('Excluded Names: <info>%s</info> ' , $ config ->getExcludedNames () ? implode (', ' , $ config ->getExcludedNames ()) : '# none # ' ));
119
- $ output ->writeln (sprintf ('Output-Format: <info>%s</info> ' , $ config ->getOutputFormat () ? $ config ->getOutputFormat () : '# whatever is present, if nothing then ' . $ config ->getDefaultOutputFormat (). ' # ' ));
116
+ $ output ->writeln (sprintf ('Output-Format: <info>%s</info> ' , $ config ->getOutputFormat () ? $ config ->getOutputFormat () : '# whatever is present, if nothing then ' . $ config ->getDefaultOutputFormat () . ' # ' ));
120
117
$ output ->writeln (sprintf ('Custom Extractors: <info>%s</info> ' , $ config ->getEnabledExtractors () ? implode (', ' , array_keys ($ config ->getEnabledExtractors ())) : '# none # ' ));
121
118
$ output ->writeln ('============================================================ ' );
122
119
@@ -129,20 +126,20 @@ protected function execute(InputInterface $input, OutputInterface $output): int
129
126
if ($ input ->getOption ('dry-run ' )) {
130
127
$ changeSet = $ this ->updater ->getChangeSet ($ config );
131
128
132
- $ output ->writeln ('Added Messages: ' . count ($ changeSet ->getAddedMessages ()));
129
+ $ output ->writeln ('Added Messages: ' . count ($ changeSet ->getAddedMessages ()));
133
130
if ($ input ->hasParameterOption ('--verbose ' )) {
134
131
foreach ($ changeSet ->getAddedMessages () as $ message ) {
135
- $ output ->writeln ($ message ->getId (). '-> ' . $ message ->getDesc ());
132
+ $ output ->writeln ($ message ->getId () . '-> ' . $ message ->getDesc ());
136
133
}
137
134
}
138
135
139
136
if ($ config ->isKeepOldMessages ()) {
140
137
$ output ->writeln ('Deleted Messages: # none as "Keep Old Translations" is true # ' );
141
138
} else {
142
- $ output ->writeln ('Deleted Messages: ' . count ($ changeSet ->getDeletedMessages ()));
139
+ $ output ->writeln ('Deleted Messages: ' . count ($ changeSet ->getDeletedMessages ()));
143
140
if ($ input ->hasParameterOption ('--verbose ' )) {
144
141
foreach ($ changeSet ->getDeletedMessages () as $ message ) {
145
- $ output ->writeln ($ message ->getId (). '-> ' . $ message ->getDesc ());
142
+ $ output ->writeln ($ message ->getId () . '-> ' . $ message ->getDesc ());
146
143
}
147
144
}
148
145
}
@@ -158,10 +155,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
158
155
return 0 ;
159
156
}
160
157
161
- /**
162
- * @param InputInterface $input
163
- * @param ConfigBuilder $builder
164
- */
165
158
private function updateWithInput (InputInterface $ input , ConfigBuilder $ builder )
166
159
{
167
160
if ($ bundle = $ input ->getOption ('bundle ' )) {
@@ -170,8 +163,8 @@ private function updateWithInput(InputInterface $input, ConfigBuilder $builder)
170
163
}
171
164
172
165
$ bundle = $ this ->getApplication ()->getKernel ()->getBundle ($ bundle );
173
- $ builder ->setTranslationsDir ($ bundle ->getPath (). '/Resources/translations ' );
174
- $ builder ->setScanDirs (array ( $ bundle ->getPath ()) );
166
+ $ builder ->setTranslationsDir ($ bundle ->getPath () . '/Resources/translations ' );
167
+ $ builder ->setScanDirs ([ $ bundle ->getPath ()] );
175
168
}
176
169
177
170
if ($ dirs = $ input ->getOption ('dir ' )) {
0 commit comments