1
0
Fork 0

Merge pull request #2988 from tristanlins/feature/composer-repository-find-packages

ComposerRepository::findPackage[s]
pull/2995/merge
Jordi Boggiano 2014-06-05 10:55:27 +02:00
commit 58d01b2c6e
1 changed files with 52 additions and 0 deletions

View File

@ -98,6 +98,58 @@ class ComposerRepository extends ArrayRepository implements StreamableRepository
$this->rootAliases = $rootAliases;
}
/**
* {@inheritDoc}
*/
public function findPackage($name, $version)
{
// normalize version & name
$versionParser = new VersionParser();
$version = $versionParser->normalize($version);
$name = strtolower($name);
foreach ($this->getProviderNames() as $providerName) {
if ($name === $providerName) {
$packages = $this->whatProvides(new Pool('dev'), $providerName);
foreach ($packages as $package) {
if ($name == $package->getName() && $version === $package->getVersion()) {
return $package;
}
}
}
}
}
/**
* {@inheritDoc}
*/
public function findPackages($name, $version = null)
{
// normalize name
$name = strtolower($name);
// normalize version
if (null !== $version) {
$versionParser = new VersionParser();
$version = $versionParser->normalize($version);
}
$packages = array();
foreach ($this->getProviderNames() as $providerName) {
if ($name === $providerName) {
$packages = $this->whatProvides(new Pool('dev'), $providerName);
foreach ($packages as $package) {
if ($name == $package->getName() && (null === $version || $version === $package->getVersion())) {
$packages[] = $package;
}
}
}
}
return $packages;
}
public function getPackages()
{
if ($this->hasProviders()) {