From a5edc9e357aba73978d33b91fba1fabac9ffe778 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 15 Mar 2012 01:49:29 +0100 Subject: [PATCH] Extract package purging in a method and fix variable overriding --- src/Composer/Factory.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index 30763e886..958844930 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -94,11 +94,7 @@ class Factory $im = $this->createInstallationManager($rm, $dm, $vendorDir, $binDir, $io); // purge packages if they have been deleted on the filesystem - foreach ($rm->getLocalRepository()->getPackages() as $package) { - if (!$im->isPackageInstalled($package)) { - $rm->getLocalRepository()->removePackage($package); - } - } + $this->purgePackages($rm, $im); // init locker $lockFile = substr($composerFile, -5) === '.json' ? substr($composerFile, 0, -4).'lock' : $composerFile . '.lock'; @@ -187,6 +183,15 @@ class Factory return $im; } + protected function purgePackages(Repository\RepositoryManager $rm, Installer\InstallationManager $im) + { + foreach ($rm->getLocalRepository()->getPackages() as $package) { + if (!$im->isPackageInstalled($package)) { + $rm->getLocalRepository()->removePackage($package); + } + } + } + static public function create(IOInterface $io, $composerFile = null) { $factory = new static();