1
0
Fork 0

Fix root aliasing with new providers repo format

pull/1020/merge
Jordi Boggiano 2012-10-24 16:11:32 +02:00
parent cac0e71d45
commit 125ff3e4f5
2 changed files with 28 additions and 0 deletions

View File

@ -83,6 +83,7 @@ class Pool
if ($repo instanceof ComposerRepository && $repo->hasProviders()) { if ($repo instanceof ComposerRepository && $repo->hasProviders()) {
$this->composerRepos[] = $repo; $this->composerRepos[] = $repo;
$repo->setRootAliases($rootAliases);
$repo->resetPackageIds(); $repo->resetPackageIds();
} elseif ($repo instanceof StreamableRepositoryInterface) { } elseif ($repo instanceof StreamableRepositoryInterface) {
foreach ($repo->getMinimalPackages() as $package) { foreach ($repo->getMinimalPackages() as $package) {

View File

@ -40,6 +40,7 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository
protected $providers = array(); protected $providers = array();
protected $providersByUid = array(); protected $providersByUid = array();
protected $loader; protected $loader;
protected $rootAliases;
private $rawData; private $rawData;
private $minimalPackages; private $minimalPackages;
private $degradedMode = false; private $degradedMode = false;
@ -103,6 +104,11 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository
@file_get_contents($url, false, $context); @file_get_contents($url, false, $context);
} }
public function setRootAliases(array $rootAliases)
{
$this->rootAliases = $rootAliases;
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -250,6 +256,10 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository
} else { } else {
$this->providers[$name][$version['uid']] = $this->providersByUid[$version['uid']]; $this->providers[$name][$version['uid']] = $this->providersByUid[$version['uid']];
} }
// check for root aliases
if (isset($this->providersByUid[$version['uid'].'-root'])) {
$this->providers[$name][$version['uid'].'-root'] = $this->providersByUid[$version['uid'].'-root'];
}
} }
} else { } else {
if (!$pool->isPackageAcceptable($version['name'], VersionParser::parseStability($version['version']))) { if (!$pool->isPackageAcceptable($version['name'], VersionParser::parseStability($version['version']))) {
@ -271,6 +281,23 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository
// override provider with its alias so it can be expanded in the if block above // override provider with its alias so it can be expanded in the if block above
$this->providersByUid[$version['uid']] = $alias; $this->providersByUid[$version['uid']] = $alias;
} }
// handle root package aliases
unset($rootAliasData);
if (isset($this->rootAliases[$name][$package->getVersion()])) {
$rootAliasData = $this->rootAliases[$name][$package->getVersion()];
} elseif (($aliasNormalized = $package->getAlias()) && isset($this->rootAliases[$name][$aliasNormalized])) {
$rootAliasData = $this->rootAliases[$name][$aliasNormalized];
}
if (isset($rootAliasData)) {
$alias = $this->createAliasPackage($package, $rootAliasData['alias_normalized'], $rootAliasData['alias']);
$alias->setRepository($this);
$this->providers[$name][$version['uid'].'-root'] = $alias;
$this->providersByUid[$version['uid'].'-root'] = $alias;
}
} }
} }
} }