1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
updatecommand.php
См. документацию.
1<?php
2
3namespace Bitrix\Main\Cli\Command\Update;
4
5use Symfony\Component\Console\Command\Command;
6use Symfony\Component\Console\Input\InputInterface;
7use Symfony\Component\Console\Output\OutputInterface;
8use Symfony\Component\Console\Style\SymfonyStyle;
9use Bitrix\Main\Cli\Command\Update\Service\UpdaterService;
10
11abstract class UpdateCommand extends Command
12{
14 protected SymfonyStyle $io;
15
16 protected function execute(InputInterface $input, OutputInterface $output): int
17 {
18 $this->updater = new UpdaterService();
19 $this->io = new SymfonyStyle($input, $output);
20
21 $result = $this->updater->listUpdates();
22
23 if (!$result->isSuccess())
24 {
25 $this->io->error((string)$result->getError());
26 return self::FAILURE;
27 }
28
29 $updateList = $result->getData();
30
31 if (isset($updateList['REPAIR']))
32 {
33 if (!$this->repair($updateList['REPAIR']))
34 {
35 return self::FAILURE;
36 }
37 }
38
39 if (isset($updateList['CLIENT']))
40 {
41 $this->showClientInfo($updateList['CLIENT']);
42 }
43
44 if (isset($updateList['UPDATE_SYSTEM']))
45 {
46 return $this->upgradeUpdateSystem() ? self::SUCCESS : self::FAILURE;
47 }
48
49 if (!$this->executeCommand($updateList, $input))
50 {
51 return self::FAILURE;
52 }
53
54 return self::SUCCESS;
55 }
56
57 protected function repair(array $repair): bool
58 {
59 $result = $this->updater->repair($repair[0]['@']['TYPE']);
60 if (!$result->isSuccess())
61 {
62 $this->io->error((string)$result->getError());
63 return false;
64 }
65 return true;
66 }
67
68 protected function showClientInfo(array $client): void
69 {
70 $this->io->title('Client information');
71 $this->io->writeln('Name: ' . ($client[0]['@']['NAME'] ?? 'n/a'));
72 $this->io->writeln('Product: ' . ($client[0]["@"]['LICENSE'] ?? 'n/a'));
73 }
74
75 protected function upgradeUpdateSystem(): bool
76 {
77 $this->io->info('Upgrade of the Update System is required.');
78
79 if ($this->io->confirm('Upgrade the Update System?'))
80 {
81 $result = $this->updater->updateUpdateSystem();
82 if ($result->isSuccess())
83 {
84 $this->io->success('Update System upgraded successfully. Restart the command.');
85 return true;
86 }
87 $this->io->error((string)$result->getError());
88 }
89 return false;
90 }
91
92 abstract protected function executeCommand(array $updateList, InputInterface $input): bool;
93}
execute(InputInterface $input, OutputInterface $output)
Определения updatecommand.php:16
executeCommand(array $updateList, InputInterface $input)
</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
$output
Определения options.php:436