Reuse repository manager and others directly from the Composer instance, refs #9057
parent
1d3af13c22
commit
eac03e16e7
|
@ -288,13 +288,13 @@ EOT
|
|||
}
|
||||
|
||||
$composer = Factory::create($io, $config->all(), $disablePlugins);
|
||||
$eventDispatcher = $composer->getEventDispatcher();
|
||||
$config = $composer->getConfig();
|
||||
$rm = $composer->getRepositoryManager();
|
||||
|
||||
if (null === $repository) {
|
||||
$rm = RepositoryFactory::manager($io, $config, $eventDispatcher, Factory::createRemoteFilesystem($io, $config));
|
||||
$sourceRepo = new CompositeRepository(RepositoryFactory::defaultRepos($io, $config, $rm));
|
||||
} else {
|
||||
$sourceRepo = RepositoryFactory::fromString($io, $config, $repository, true);
|
||||
$sourceRepo = RepositoryFactory::fromString($io, $config, $repository, true, $rm);
|
||||
}
|
||||
|
||||
$parser = new VersionParser();
|
||||
|
@ -389,13 +389,13 @@ EOT
|
|||
$package = $package->getAliasOf();
|
||||
}
|
||||
|
||||
$dm = $this->createDownloadManager($io, $config, $eventDispatcher);
|
||||
$dm = $composer->getDownloadManager();
|
||||
$dm->setPreferSource($preferSource)
|
||||
->setPreferDist($preferDist)
|
||||
->setOutputProgress(!$noProgress);
|
||||
|
||||
$projectInstaller = new ProjectInstaller($directory, $dm);
|
||||
$im = $this->createInstallationManager();
|
||||
$im = $composer->getInstallationManager();
|
||||
$im->addInstaller($projectInstaller);
|
||||
$im->install(new InstalledFilesystemRepository(new JsonFile('php://memory')), new InstallOperation($package));
|
||||
$im->notifyInstalls($io);
|
||||
|
@ -413,16 +413,4 @@ EOT
|
|||
|
||||
return $installedFromVcs;
|
||||
}
|
||||
|
||||
protected function createDownloadManager(IOInterface $io, Config $config, EventDispatcher $eventDispatcher)
|
||||
{
|
||||
$factory = new Factory();
|
||||
|
||||
return $factory->createDownloadManager($io, $config, $eventDispatcher);
|
||||
}
|
||||
|
||||
protected function createInstallationManager()
|
||||
{
|
||||
return new InstallationManager();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,11 +62,11 @@ class RepositoryFactory
|
|||
* @param bool $allowFilesystem
|
||||
* @return RepositoryInterface
|
||||
*/
|
||||
public static function fromString(IOInterface $io, Config $config, $repository, $allowFilesystem = false)
|
||||
public static function fromString(IOInterface $io, Config $config, $repository, $allowFilesystem = false, RepositoryManager $rm = null)
|
||||
{
|
||||
$repoConfig = static::configFromString($io, $config, $repository, $allowFilesystem);
|
||||
|
||||
return static::createRepo($io, $config, $repoConfig);
|
||||
return static::createRepo($io, $config, $repoConfig, $rm);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,9 +75,11 @@ class RepositoryFactory
|
|||
* @param array $repoConfig
|
||||
* @return RepositoryInterface
|
||||
*/
|
||||
public static function createRepo(IOInterface $io, Config $config, array $repoConfig)
|
||||
public static function createRepo(IOInterface $io, Config $config, array $repoConfig, RepositoryManager $rm = null)
|
||||
{
|
||||
$rm = static::manager($io, $config, null, Factory::createRemoteFilesystem($io, $config));
|
||||
if (!$rm) {
|
||||
$rm = static::manager($io, $config, null, Factory::createRemoteFilesystem($io, $config));
|
||||
}
|
||||
$repos = static::createRepos($rm, array($repoConfig));
|
||||
|
||||
return reset($repos);
|
||||
|
|
Loading…
Reference in New Issue