Skip to content

Commit

Permalink
Update composer
Browse files Browse the repository at this point in the history
  • Loading branch information
yunbaoi committed Oct 19, 2021
1 parent 07763f4 commit 8805dc0
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions src/core/Server/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,29 +353,31 @@ function (Server $server, $msg) {
'get_composer_packages',
$accepted_process_types,
function (Server $server, $msg) {
if (!class_exists(\Composer\InstalledVersions::class)) {
return self::json('require composer 2.0', 4003);
}

$list = [];
if (class_exists(\Composer\InstalledVersions::class)) {
foreach (['getAllRawData', 'getRawData'] as $method) {
if (method_exists(\Composer\InstalledVersions::class, $method)) {
if ($method === 'getAllRawData') {
$raw_data = \Composer\InstalledVersions::$method();
array_shift($raw_data);
} else {
$raw_data[] = \Composer\InstalledVersions::$method();
}
foreach ($raw_data as $key => $package) {
$key_name = $package['root']['name'];
if ($package['root']['name'] === '__root__' && isset($list['__root__'])) {
$key_name = "__root__{$key}";
}
$package['root']['install_path'] = realpath($package['root']['install_path']);
$list[$key_name] = $package;
}
break;
foreach (['getAllRawData', 'getRawData'] as $method) {
if (!method_exists(\Composer\InstalledVersions::class, $method)) {
continue;
}

$raw_data[] = \Composer\InstalledVersions::$method();
if ($method === 'getAllRawData') {
$raw_data = \Composer\InstalledVersions::$method();
array_shift($raw_data);
}

foreach ($raw_data as $key => $package) {
$key_name = $package['root']['name'];
if ($package['root']['name'] === '__root__' && isset($list['__root__'])) {
$key_name = "__root__{$key}";
}
$package['root']['install_path'] = realpath($package['root']['install_path']);
$list[$key_name] = $package;
}
} else {
return self::json('require composer 2.0', 4003);
break;
}
return self::json($list);
}
Expand Down

0 comments on commit 8805dc0

Please sign in to comment.