|
|
|
@ -26,6 +26,8 @@ use Composer\Util\RemoteFilesystem;
|
|
|
|
|
use Composer\Plugin\PluginEvents;
|
|
|
|
|
use Composer\Plugin\PreFileDownloadEvent;
|
|
|
|
|
use Composer\EventDispatcher\EventDispatcher;
|
|
|
|
|
use Composer\Package\LinkConstraint\LinkConstraintInterface;
|
|
|
|
|
use Composer\Package\LinkConstraint\VersionConstraint;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
|
|
|
@ -99,22 +101,27 @@ class ComposerRepository extends ArrayRepository
|
|
|
|
|
/**
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
|
|
|
|
public function findPackage($name, $version)
|
|
|
|
|
public function findPackage($name, $constraint)
|
|
|
|
|
{
|
|
|
|
|
if (!$this->hasProviders()) {
|
|
|
|
|
return parent::findPackage($name, $version);
|
|
|
|
|
return parent::findPackage($name, $constraint);
|
|
|
|
|
}
|
|
|
|
|
// normalize version & name
|
|
|
|
|
$versionParser = new VersionParser();
|
|
|
|
|
$version = $versionParser->normalize($version);
|
|
|
|
|
|
|
|
|
|
$name = strtolower($name);
|
|
|
|
|
if (!$constraint instanceof LinkConstraintInterface) {
|
|
|
|
|
$versionParser = new VersionParser();
|
|
|
|
|
$constraint = $versionParser->parseConstraints($constraint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
if ($name === $package->getName()) {
|
|
|
|
|
$pkgConstraint = new VersionConstraint('==', $package->getVersion());
|
|
|
|
|
if ($constraint->matches($pkgConstraint)) {
|
|
|
|
|
return $package;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -124,28 +131,30 @@ class ComposerRepository extends ArrayRepository
|
|
|
|
|
/**
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
|
|
|
|
public function findPackages($name, $version = null)
|
|
|
|
|
public function findPackages($name, $constraint = null)
|
|
|
|
|
{
|
|
|
|
|
if (!$this->hasProviders()) {
|
|
|
|
|
return parent::findPackages($name, $version);
|
|
|
|
|
return parent::findPackages($name, $constraint);
|
|
|
|
|
}
|
|
|
|
|
// normalize name
|
|
|
|
|
$name = strtolower($name);
|
|
|
|
|
|
|
|
|
|
// normalize version
|
|
|
|
|
if (null !== $version) {
|
|
|
|
|
if (null !== $constraint && !$constraint instanceof LinkConstraintInterface) {
|
|
|
|
|
$versionParser = new VersionParser();
|
|
|
|
|
$version = $versionParser->normalize($version);
|
|
|
|
|
$constraint = $versionParser->parseConstraints($constraint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$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;
|
|
|
|
|
$candidates = $this->whatProvides(new Pool('dev'), $providerName);
|
|
|
|
|
foreach ($candidates as $package) {
|
|
|
|
|
if ($name === $package->getName()) {
|
|
|
|
|
$pkgConstraint = new VersionConstraint('==', $package->getVersion());
|
|
|
|
|
if (null === $constraint || $constraint->matches($pkgConstraint)) {
|
|
|
|
|
$packages[] = $package;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|