Create links/constraints between packages

main
Jordi Boggiano 13 years ago
parent b53a3086b6
commit d185194d1a

@ -14,6 +14,8 @@ namespace Composer\Repository;
use Composer\Package\MemoryPackage; use Composer\Package\MemoryPackage;
use Composer\Package\BasePackage; use Composer\Package\BasePackage;
use Composer\Package\Link;
use Composer\Package\LinkConstraint\VersionConstraint;
/** /**
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
@ -52,25 +54,36 @@ class ComposerRepository extends ArrayRepository
if (isset($rev['license'])) { if (isset($rev['license'])) {
$package->setLicense($rev['license']); $package->setLicense($rev['license']);
} }
//if (isset($rev['require'])) {
// $package->setRequires($rev['require']); $links = array(
//} 'require',
//if (isset($rev['conflict'])) { 'conflict',
// $package->setConflicts($rev['conflict']); 'provide',
//} 'replace',
//if (isset($rev['provide'])) { 'recommend',
// $package->setProvides($rev['provide']); 'suggest',
//} );
//if (isset($rev['replace'])) { foreach ($links as $link) {
// $package->setReplaces($rev['replace']); if (isset($rev[$link])) {
//} $method = 'set'.$link.'s';
//if (isset($rev['recommend'])) { $package->{$method}($this->createLinks($rev['name'], $link.'s', $rev[$link]));
// $package->setRecommends($rev['recommend']); }
//} }
//if (isset($rev['suggest'])) {
// $package->setSuggests($rev['suggest']);
//}
$this->addPackage($package); $this->addPackage($package);
} }
} }
protected function createLinks($name, $description, $linkSpecs)
{
$links = array();
foreach ($linkSpecs as $dep => $ver) {
preg_match('#^([>=<~]*)([\d.]+.*)$#', $ver, $match);
if (!$match[1]) {
$match[1] = '=';
}
$constraint = new VersionConstraint($match[1], $match[2]);
$links[] = new Link($name, $dep, $constraint, $description);
}
return $links;
}
} }
Loading…
Cancel
Save