Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 33 additions & 20 deletions setup/src/Magento/Setup/Model/PackagesData.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ public function getPackagesForInstall()
}

/**
* Get MetaPackage for package
*
* @param array $packages
* @return array
Expand Down Expand Up @@ -377,26 +378,38 @@ private function getPackageAvailableVersions($package)

return array_keys($packageVersions);
}
} else {
$versionsPattern = '/^versions\s*\:\s(.+)$/m';

$commandParams = [
self::PARAM_COMMAND => self::COMPOSER_SHOW,
self::PARAM_PACKAGE => $package,
self::PARAM_AVAILABLE => true
];

$applicationFactory = $this->objectManagerProvider->get()
->get('Magento\Framework\Composer\MagentoComposerApplicationFactory');
/** @var \Magento\Composer\MagentoComposerApplication $application */
$application = $applicationFactory->create();

$result = $application->runComposerCommand($commandParams);
$matches = [];
preg_match($versionsPattern, $result, $matches);
if (isset($matches[1])) {
return explode(', ', $matches[1]);
}
}

return $this->getAvailableVersionsFromAllRepositories($package);
}

/**
* Get available versions of package by "composer show" command
*
* @param string $package
* @return array
* @exception \RuntimeException
*/
private function getAvailableVersionsFromAllRepositories($package)
{
$versionsPattern = '/^versions\s*\:\s(.+)$/m';

$commandParams = [
self::PARAM_COMMAND => self::COMPOSER_SHOW,
self::PARAM_PACKAGE => $package,
self::PARAM_AVAILABLE => true
];

$applicationFactory = $this->objectManagerProvider->get()
->get(\Magento\Framework\Composer\MagentoComposerApplicationFactory::class);
/** @var \Magento\Composer\MagentoComposerApplication $application */
$application = $applicationFactory->create();

$result = $application->runComposerCommand($commandParams);
$matches = [];
preg_match($versionsPattern, $result, $matches);
if (isset($matches[1])) {
return explode(', ', $matches[1]);
}

throw new \RuntimeException(
Expand Down