@ -183,6 +193,9 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
return array();
}
return parent::findPackages($name, $constraint);
}
private function filterPackages(array $packages, $constraint = null, $returnFirstMatch = false)
{
if (null === $constraint) {
@ -216,7 +229,22 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
public function getPackages()
{
if ($this->hasProviders()) {
$hasProviders = $this->hasProviders();
if ($this->lazyProvidersUrl) {
if (is_array($this->availablePackages)) {
$packageMap = array();
foreach ($this->availablePackages as $name) {
$packageMap[$name] = new EmptyConstraint();
}
return array_values($this->loadAsyncPackages($packageMap, function ($name, $stability) { return true; }));
}
throw new \LogicException('Composer repositories that have lazy providers and no available-packages list can not load the complete list of packages, use getProviderNames instead.');
}
if ($hasProviders) {
throw new \LogicException('Composer repositories that have providers can not load the complete list of packages, use getProviderNames instead.');
}
@ -225,14 +253,28 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
public function getPackageNames()
{
if ($this->hasProviders()) {
// TODO add getPackageNames to the RepositoryInterface perhaps? With filtering capability embedded?
$hasProviders = $this->hasProviders();
if ($this->lazyProvidersUrl) {
if (is_array($this->availablePackages)) {
return array_keys($this->availablePackages);
}
// TODO implement new list API endpoint for those repos somehow?
return array();
}
if ($hasProviders) {
return $this->getProviderNames();
}
// TODO implement new list API endpoint for repos somehow?
// TODO add getPackageNames to the RepositoryInterface perhaps? With filtering capability embedded?
$names = array();
foreach ($this->getPackages() as $package) {
$names[] = $package->getPrettyName();
}
return $this->getPackages();
return $names;
}
public function loadPackages(array $packageNameMap, $isPackageAcceptableCallable)
@ -279,11 +321,16 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
unset($packageNameMap[$name]);
}
return $packages;
}
if ($this->lazyProvidersUrl && count($packageNameMap)) {
if (is_array($this->availablePackages)) {
$availPackages = $this->availablePackages;
$packageNameMap = array_filter($packageNameMap, function ($name) use ($availPackages) {
// provides a list of package names that are available in this repo
// this disables lazy-provider behavior in the sense that if a list is available we assume it is finite and won't search for other packages in that repo
// while if no list is there lazyProvidersUrl is used when looking for any package name to see if the repo knows it