1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
languagescommand.php
См. документацию.
1<?php
2
4
5use Symfony\Component\Console\Input\InputInterface;
6use Symfony\Component\Console\Input\InputOption;
7
18{
19 protected function configure()
20 {
21 $this
22 ->setName('update:languages')
23 ->setDescription('Updates language files.')
24 ->addOption('languages', 'l', InputOption::VALUE_REQUIRED, 'Comma separated list of language codes to update.')
25 ;
26 }
27
28 protected function executeCommand(array $updateList, InputInterface $input): bool
29 {
30 if (isset($updateList["LANGS"][0]["#"]["INST"][0]["#"]["LANG"]))
31 {
32 $this->showUpdates($updateList["LANGS"][0]["#"]["INST"][0]["#"]["LANG"]);
33
34 if (!$this->installUpdates($updateList["LANGS"][0]["#"]["INST"][0]["#"]["LANG"], $input->getOption('languages')))
35 {
36 return false;
37 }
38 }
39 else
40 {
41 $this->io->info('No updates found.');
42 }
43
44 return true;
45 }
46
47 protected function installUpdates(array $updateList, ?string $inputLanguages): bool
48 {
49 $selectedLanguages = [];
50 if (!empty($inputLanguages))
51 {
52 $selectedLanguages = explode(',', $inputLanguages);
53 }
54
55 $languages = [];
56 foreach ($updateList as $language)
57 {
58 $languageId = $language["@"]["ID"];
59 if (empty($selectedLanguages) || in_array($languageId, $selectedLanguages))
60 {
61 $languages[$languageId] = '[' . $languageId . '] '. $language["@"]["NAME"] . ' (' . $language["@"]["DATE"] . ')';
62 }
63 }
64
65 if (!empty($languages))
66 {
67 if (!empty($selectedLanguages))
68 {
69 ksort($languages);
70
71 $this->io->title('Language files to install');
72 foreach ($languages as $language)
73 {
74 $this->io->writeln($language);
75 }
76 }
77
78 if ($this->io->confirm('Install updates?'))
79 {
80 $result = $this->updater->installLanguages(array_keys($languages), $this->io);
81 if ($result->isSuccess())
82 {
83 $this->io->success('Updates installed successfully.');
84 }
85 else
86 {
87 $this->io->error((string)$result->getError());
88 return false;
89 }
90 }
91 }
92 else
93 {
94 $this->io->info('No languages selected.');
95 }
96
97 return true;
98 }
99
100 protected function showUpdates(array $updateList): void
101 {
102 $this->io->title('Available language files updates');
103
104 $updates = [];
105 foreach ($updateList as $language)
106 {
107 $updates[] = '[' . $language["@"]["ID"] . '] '. $language["@"]["NAME"] . ' (' . $language["@"]["DATE"] . ')';
108 }
109 sort($updates);
110
111 $this->io->write($updates, true);
112 }
113}
executeCommand(array $updateList, InputInterface $input)
Определения languagescommand.php:28
installUpdates(array $updateList, ?string $inputLanguages)
Определения languagescommand.php:47
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14