Hide installed packages from suggestions when package is not found
parent
f753c15664
commit
a8abdd9639
|
@ -792,7 +792,13 @@ EOT
|
||||||
}
|
}
|
||||||
$similarPackages = array();
|
$similarPackages = array();
|
||||||
|
|
||||||
|
$installedRepo = $this->getComposer()->getRepositoryManager()->getLocalRepository();
|
||||||
|
|
||||||
foreach ($results as $result) {
|
foreach ($results as $result) {
|
||||||
|
if ($installedRepo->hasPackageName($result['name'])) {
|
||||||
|
// Ignore installed package
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$similarPackages[$result['name']] = levenshtein($package, $result['name']);
|
$similarPackages[$result['name']] = levenshtein($package, $result['name']);
|
||||||
}
|
}
|
||||||
asort($similarPackages);
|
asort($similarPackages);
|
||||||
|
|
|
@ -132,6 +132,20 @@ class ArrayRepository extends BaseRepository
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function hasPackageName(string $packageName)
|
||||||
|
{
|
||||||
|
foreach ($this->getPackages() as $repoPackage) {
|
||||||
|
if ($packageName === $repoPackage->getName()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new package to the repository
|
* Adds a new package to the repository
|
||||||
*
|
*
|
||||||
|
|
|
@ -64,6 +64,21 @@ class CompositeRepository extends BaseRepository
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function hasPackageName(string $packageName)
|
||||||
|
{
|
||||||
|
foreach ($this->repositories as $repository) {
|
||||||
|
/* @var $repository RepositoryInterface */
|
||||||
|
if ($repository->hasPackageName($packageName)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -35,6 +35,15 @@ interface RepositoryInterface extends \Countable
|
||||||
*/
|
*/
|
||||||
public function hasPackage(PackageInterface $package);
|
public function hasPackage(PackageInterface $package);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if specified package name is registered (installed).
|
||||||
|
*
|
||||||
|
* @param string $package_name package name (vendor/project)
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasPackageName(string $packageName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches for the first match of a package by name and version.
|
* Searches for the first match of a package by name and version.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue