1
|
|
|
<?php |
2
|
|
|
namespace Shlinkio\Shlink\CLI\Install\Plugin; |
3
|
|
|
|
4
|
|
|
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig; |
5
|
|
|
use Symfony\Component\Console\Exception\RuntimeException; |
6
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
7
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
8
|
|
|
use Symfony\Component\Console\Question\ChoiceQuestion; |
9
|
|
|
use Symfony\Component\Console\Question\ConfirmationQuestion; |
10
|
|
|
|
11
|
|
|
class LanguageConfigCustomizerPlugin extends AbstractConfigCustomizerPlugin |
12
|
|
|
{ |
13
|
|
|
const SUPPORTED_LANGUAGES = ['en', 'es']; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @param InputInterface $input |
17
|
|
|
* @param OutputInterface $output |
18
|
|
|
* @param CustomizableAppConfig $appConfig |
19
|
|
|
* @return void |
20
|
|
|
* @throws RuntimeException |
21
|
|
|
*/ |
22
|
3 |
|
public function process(InputInterface $input, OutputInterface $output, CustomizableAppConfig $appConfig) |
23
|
|
|
{ |
24
|
3 |
|
$this->printTitle($output, 'LANGUAGE'); |
25
|
|
|
|
26
|
3 |
|
if ($appConfig->hasLanguage() && $this->questionHelper->ask($input, $output, new ConfirmationQuestion( |
27
|
|
|
'<question>Do you want to keep imported language? (Y/n):</question> ' |
28
|
3 |
|
))) { |
29
|
1 |
|
return; |
30
|
|
|
} |
31
|
|
|
|
32
|
2 |
|
$appConfig->setLanguage([ |
33
|
2 |
|
'DEFAULT' => $this->questionHelper->ask($input, $output, new ChoiceQuestion( |
34
|
|
|
'<question>Select default language for the application in general (defaults to ' |
35
|
2 |
|
. self::SUPPORTED_LANGUAGES[0] . '):</question>', |
36
|
2 |
|
self::SUPPORTED_LANGUAGES, |
37
|
|
|
0 |
38
|
2 |
|
)), |
39
|
2 |
|
'CLI' => $this->questionHelper->ask($input, $output, new ChoiceQuestion( |
40
|
|
|
'<question>Select default language for CLI executions (defaults to ' |
41
|
2 |
|
. self::SUPPORTED_LANGUAGES[0] . '):</question>', |
42
|
2 |
|
self::SUPPORTED_LANGUAGES, |
43
|
|
|
0 |
44
|
2 |
|
)), |
45
|
2 |
|
]); |
46
|
2 |
|
} |
47
|
|
|
} |
48
|
|
|
|