diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 849884d1c..8e49eedb5 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -177,7 +177,7 @@ class Application extends BaseApplication public function renderException($exception, $output) { try { - $composer = $this->getComposer(false); + $composer = $this->getComposer(false, true); if ($composer) { $config = $composer->getConfig(); diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index 5b2539672..8f7ba28e0 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -283,18 +283,19 @@ class Factory // add installers to the manager (must happen after download manager is created since they read it out of $composer) $this->createDefaultInstallers($im, $composer, $io); - $globalComposer = $this->createGlobalComposer($io, $config, $disablePlugins); - $globalRepository = $globalComposer ? $globalComposer->getRepositoryManager()->getLocalRepository() : null; - $pm = $this->createPluginManager($composer, $io, $globalRepository); - $composer->setPluginManager($pm); - // purge packages if they have been deleted on the filesystem if ($rm->getLocalRepository()) { $this->purgePackages($rm->getLocalRepository(), $im); } - if (!$disablePlugins) { - $pm->loadInstalledPlugins(); + if ($fullLoad) { + $globalComposer = $this->createGlobalComposer($io, $config, $disablePlugins); + $pm = $this->createPluginManager($io, $composer, $globalComposer); + $composer->setPluginManager($pm); + + if (!$disablePlugins) { + $pm->loadInstalledPlugins(); + } } // init locker if possible @@ -424,14 +425,14 @@ class Factory } /** - * @param Composer $composer * @param IOInterface $io - * @param RepositoryInterface $globalRepository + * @param Composer $composer + * @param Composer $globalComposer * @return Plugin\PluginManager */ - protected function createPluginManager(Composer $composer, IOInterface $io, RepositoryInterface $globalRepository = null) + protected function createPluginManager(IOInterface $io, Composer $composer, Composer $globalComposer = null) { - return new Plugin\PluginManager($composer, $io, $globalRepository); + return new Plugin\PluginManager($io, $composer, $globalComposer); } /** diff --git a/src/Composer/Plugin/PluginManager.php b/src/Composer/Plugin/PluginManager.php index fdd952ae3..d7c2d8657 100644 --- a/src/Composer/Plugin/PluginManager.php +++ b/src/Composer/Plugin/PluginManager.php @@ -28,12 +28,13 @@ use Composer\DependencyResolver\Pool; * Plugin manager * * @author Nils Adermann + * @author Jordi Boggiano */ class PluginManager { protected $composer; protected $io; - protected $globalRepository; + protected $globalComposer; protected $versionParser; protected $plugins = array(); @@ -44,15 +45,15 @@ class PluginManager /** * Initializes plugin manager * - * @param Composer $composer * @param IOInterface $io - * @param RepositoryInterface $globalRepository + * @param Composer $composer + * @param Composer $globalComposer */ - public function __construct(Composer $composer, IOInterface $io, RepositoryInterface $globalRepository = null) + public function __construct(IOInterface $io, Composer $composer, Composer $globalComposer = null) { - $this->composer = $composer; $this->io = $io; - $this->globalRepository = $globalRepository; + $this->composer = $composer; + $this->globalComposer = $globalComposer; $this->versionParser = new VersionParser(); } @@ -62,12 +63,12 @@ class PluginManager public function loadInstalledPlugins() { $repo = $this->composer->getRepositoryManager()->getLocalRepository(); - + $globalRepo = $this->globalComposer ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null; if ($repo) { $this->loadRepository($repo); } - if ($this->globalRepository) { - $this->loadRepository($this->globalRepository); + if ($globalRepo) { + $this->loadRepository($globalRepo); } } @@ -206,11 +207,13 @@ class PluginManager } $classes = is_array($extra['class']) ? $extra['class'] : array($extra['class']); - $pool = new Pool('dev'); $localRepo = $this->composer->getRepositoryManager()->getLocalRepository(); + $globalRepo = $this->globalComposer ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null; + + $pool = new Pool('dev'); $pool->addRepository($localRepo); - if ($this->globalRepository) { - $pool->addRepository($this->globalRepository); + if ($globalRepo) { + $pool->addRepository($globalRepo); } $autoloadPackages = array($package->getName() => $package); @@ -219,7 +222,7 @@ class PluginManager $generator = $this->composer->getAutoloadGenerator(); $autoloads = array(); foreach ($autoloadPackages as $autoloadPackage) { - $downloadPath = $this->getInstallPath($autoloadPackage, ($this->globalRepository && $this->globalRepository->hasPackage($autoloadPackage))); + $downloadPath = $this->getInstallPath($autoloadPackage, ($globalRepo && $globalRepo->hasPackage($autoloadPackage))); $autoloads[] = array($autoloadPackage, $downloadPath); } @@ -261,9 +264,6 @@ class PluginManager return $this->composer->getInstallationManager()->getInstallPath($package); } - $targetDir = $package->getTargetDir(); - $vendorDir = $this->composer->getConfig()->get('home').'/vendor'; - - return ($vendorDir ? $vendorDir.'/' : '').$package->getPrettyName().($targetDir ? '/'.$targetDir : ''); + return $this->globalComposer->getInstallationManager()->getInstallPath($package); } } diff --git a/tests/Composer/Test/Plugin/PluginInstallerTest.php b/tests/Composer/Test/Plugin/PluginInstallerTest.php index 1799eb2b8..a2090082f 100644 --- a/tests/Composer/Test/Plugin/PluginInstallerTest.php +++ b/tests/Composer/Test/Plugin/PluginInstallerTest.php @@ -76,7 +76,7 @@ class PluginInstallerTest extends \PHPUnit_Framework_TestCase $this->composer->setInstallationManager($im); $this->composer->setAutoloadGenerator($this->autoloadGenerator); - $this->pm = new PluginManager($this->composer, $this->io); + $this->pm = new PluginManager($this->io, $this->composer); $this->composer->setPluginManager($this->pm); $config->merge(array(