commit
05c84e9dfd
|
@ -85,14 +85,12 @@ EOT
|
||||||
$composer->getRepositoryManager()->getRepositories()
|
$composer->getRepositoryManager()->getRepositories()
|
||||||
);
|
);
|
||||||
foreach ($repos as $repository) {
|
foreach ($repos as $repository) {
|
||||||
foreach ($repository->getPackages() as $package) {
|
foreach ($repository->findPackagesByName($input->getArgument('package')) as $package) {
|
||||||
if ($package->getName() === $input->getArgument('package')) {
|
|
||||||
if (null === $highestVersion || version_compare($package->getVersion(), $highestVersion->getVersion(), '>=')) {
|
if (null === $highestVersion || version_compare($package->getVersion(), $highestVersion->getVersion(), '>=')) {
|
||||||
$highestVersion = $package;
|
$highestVersion = $package;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $highestVersion;
|
return $highestVersion;
|
||||||
}
|
}
|
||||||
|
@ -135,12 +133,10 @@ EOT
|
||||||
$versions = array();
|
$versions = array();
|
||||||
|
|
||||||
foreach ($composer->getRepositoryManager()->getRepositories() as $repository) {
|
foreach ($composer->getRepositoryManager()->getRepositories() as $repository) {
|
||||||
foreach ($repository->getPackages() as $version) {
|
foreach ($repository->findPackagesByName($package->getName()) as $version) {
|
||||||
if ($version->getName() === $package->getName()) {
|
|
||||||
$versions[] = $version->getPrettyVersion();
|
$versions[] = $version->getPrettyVersion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$versions = join(', ', $versions);
|
$versions = join(', ', $versions);
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,19 @@ class ArrayRepository implements RepositoryInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function findPackagesByName($name)
|
||||||
|
{
|
||||||
|
// normalize name
|
||||||
|
$name = strtolower($name);
|
||||||
|
|
||||||
|
return array_filter($this->getPackages(), function (PackageInterface $package) use ($name) {
|
||||||
|
return $package->getName() === $name;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -41,6 +41,15 @@ interface RepositoryInterface extends \Countable
|
||||||
*/
|
*/
|
||||||
function findPackage($name, $version);
|
function findPackage($name, $version);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Searches for packages by it's name.
|
||||||
|
*
|
||||||
|
* @param string $name package name
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function findPackagesByName($name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns list of registered packages.
|
* Returns list of registered packages.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue