1
0
Fork 0

Clean up Installer::aliasPackages()

pull/1015/head
Jordi Boggiano 2012-08-22 15:39:16 +02:00
parent 25142c5351
commit 774021bf99
1 changed files with 23 additions and 10 deletions

View File

@ -166,7 +166,8 @@ class Installer
$installedRepo->addRepository($this->additionalInstalledRepository);
}
$aliases = $this->aliasPackages($platformRepo);
$aliases = $this->getRootAliases();
$this->aliasPlatformPackages($platformRepo, $aliases);
if ($this->runScripts) {
// dispatch pre event
@ -484,7 +485,7 @@ class Installer
return true;
}
private function aliasPackages(PlatformRepository $platformRepo)
private function getRootAliases()
{
if (!$this->update && $this->locker->isLocked()) {
$aliases = $this->locker->getAliases();
@ -495,19 +496,31 @@ class Installer
$normalizedAliases = array();
foreach ($aliases as $alias) {
$normalizedAliases[$alias['package']][$alias['version']] = array('alias' => $alias['alias'], 'alias_normalized' => $alias['alias_normalized']);
$packages = $platformRepo->findPackages($alias['package'], $alias['version']);
foreach ($packages as $package) {
$package->setAlias($alias['alias_normalized']);
$package->setPrettyAlias($alias['alias']);
$package->getRepository()->addPackage($aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']));
$aliasPackage->setRootPackageAlias(true);
}
$normalizedAliases[$alias['package']][$alias['version']] = array(
'alias' => $alias['alias'],
'alias_normalized' => $alias['alias_normalized']
);
}
return $normalizedAliases;
}
private function aliasPlatformPackages(PlatformRepository $platformRepo, $aliases)
{
foreach ($aliases as $package => $versions) {
foreach ($versions as $version => $alias) {
$packages = $platformRepo->findPackages($package, $version);
foreach ($packages as $package) {
$package->setAlias($alias['alias_normalized']);
$package->setPrettyAlias($alias['alias']);
$aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']);
$aliasPackage->setRootPackageAlias(true);
$platformRepo->addPackage($aliasPackage);
}
}
}
}
private function isUpdateable(PackageInterface $package)
{
if (!$this->updateWhitelist) {