1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
versionscommand.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Main\Cli\Command\Update;
4
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Symfony\Component\Console\Style\SymfonyStyle;
10
use Bitrix\Main\ModuleManager;
11
20
class
VersionsCommand
extends
Command
21
{
22
protected
SymfonyStyle
$io
;
23
24
protected
function
configure
()
25
{
26
$this
27
->setName(
'update:versions'
)
28
->setDescription(
'Updates modules versions.'
)
29
->addArgument(
'versions'
, InputArgument::REQUIRED,
'JSON file with modules versions.'
)
30
;
31
}
32
33
protected
function
execute
(InputInterface $input, OutputInterface
$output
): int
34
{
35
$this->io =
new
SymfonyStyle($input,
$output
);
36
37
if
(!$this->
updateVersions
($input->getArgument(
'versions'
)))
38
{
39
return
self::FAILURE;
40
}
41
42
return
self::SUCCESS;
43
}
44
45
protected
function
updateVersions
(
string
$importFile): bool
46
{
47
if
(($import = file_get_contents($importFile)) ===
false
)
48
{
49
$this->io->error(
'Import of modules versions failed (can\'t read the file).'
);
50
return
false
;
51
}
52
53
$modules
= json_decode($import,
true
);
54
if
(!is_array(
$modules
))
55
{
56
$this->io->error(
'Import of modules versions failed (JSON structure).'
);
57
return
false
;
58
}
59
60
foreach
(
$modules
as $module => $version)
61
{
62
if
(
$info
= \CModule::CreateModuleObject($module))
63
{
64
if
(version_compare(
$info
->MODULE_VERSION, $version) >= 0)
65
{
66
if
(($newVersion =
ModuleManager::decreaseVersion
($module, 1, $version)) !==
null
)
67
{
68
$this->io->writeln(
'Updated '
. $module .
' ('
.
$info
->MODULE_VERSION .
') to version '
. $newVersion);
69
}
70
}
71
}
72
else
73
{
74
$this->io->warning(
'Module '
. $module .
' not found.'
);
75
}
76
}
77
78
return
true
;
79
}
80
}
Bitrix\Main\Cli\Command\Update\VersionsCommand
Определения
versionscommand.php:21
Bitrix\Main\Cli\Command\Update\VersionsCommand\updateVersions
updateVersions(string $importFile)
Определения
versionscommand.php:45
Bitrix\Main\Cli\Command\Update\VersionsCommand\$io
SymfonyStyle $io
Определения
versionscommand.php:22
Bitrix\Main\Cli\Command\Update\VersionsCommand\configure
configure()
Определения
versionscommand.php:24
Bitrix\Main\Cli\Command\Update\VersionsCommand\execute
execute(InputInterface $input, OutputInterface $output)
Определения
versionscommand.php:33
Bitrix\Main\ModuleManager\decreaseVersion
static decreaseVersion(string $moduleId, int $count, ?string $fromVersion=null)
Определения
modulemanager.php:192
$output
$output
Определения
options.php:436
$modules
$modules
Определения
bitrix.php:26
$info
if($NS['step']==6) if( $NS[ 'step']==7) if(COption::GetOptionInt('main', 'disk_space', 0) > 0) $info
Определения
backup.php:924
bitrix
modules
main
lib
cli
command
update
versionscommand.php
Создано системой
1.14.0