Allow accessing the ArchiveManager via the Composer object, fixes #6411
parent
39d187fb1e
commit
ff61ecd484
|
@ -15,6 +15,7 @@ namespace Composer\Command;
|
|||
use Composer\Factory;
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Config;
|
||||
use Composer\Composer;
|
||||
use Composer\Repository\CompositeRepository;
|
||||
use Composer\Repository\RepositoryFactory;
|
||||
use Composer\Script\ScriptEvents;
|
||||
|
@ -84,7 +85,8 @@ EOT
|
|||
$input->getOption('format'),
|
||||
$input->getOption('dir'),
|
||||
$input->getOption('file'),
|
||||
$input->getOption('ignore-filters')
|
||||
$input->getOption('ignore-filters'),
|
||||
$composer
|
||||
);
|
||||
|
||||
if (0 === $returnCode && $composer) {
|
||||
|
@ -94,11 +96,15 @@ EOT
|
|||
return $returnCode;
|
||||
}
|
||||
|
||||
protected function archive(IOInterface $io, Config $config, $packageName = null, $version = null, $format = 'tar', $dest = '.', $fileName = null, $ignoreFilters)
|
||||
protected function archive(IOInterface $io, Config $config, $packageName = null, $version = null, $format = 'tar', $dest = '.', $fileName = null, $ignoreFilters = false, Composer $composer = null)
|
||||
{
|
||||
$factory = new Factory;
|
||||
$downloadManager = $factory->createDownloadManager($io, $config);
|
||||
$archiveManager = $factory->createArchiveManager($config, $downloadManager);
|
||||
if ($composer) {
|
||||
$archiveManager = $composer->getArchiveManager();
|
||||
} else {
|
||||
$factory = new Factory;
|
||||
$downloadManager = $factory->createDownloadManager($io, $config);
|
||||
$archiveManager = $factory->createArchiveManager($config, $downloadManager);
|
||||
}
|
||||
|
||||
if ($packageName) {
|
||||
$package = $this->selectPackage($io, $packageName, $version);
|
||||
|
|
|
@ -20,6 +20,7 @@ use Composer\Plugin\PluginManager;
|
|||
use Composer\Downloader\DownloadManager;
|
||||
use Composer\EventDispatcher\EventDispatcher;
|
||||
use Composer\Autoload\AutoloadGenerator;
|
||||
use Composer\Package\Archiver\ArchiveManager;
|
||||
|
||||
/**
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
|
@ -77,6 +78,11 @@ class Composer
|
|||
*/
|
||||
private $autoloadGenerator;
|
||||
|
||||
/**
|
||||
* @var ArchiveManager
|
||||
*/
|
||||
private $archiveManager;
|
||||
|
||||
/**
|
||||
* @param Package\RootPackageInterface $package
|
||||
* @return void
|
||||
|
@ -158,6 +164,22 @@ class Composer
|
|||
return $this->downloadManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArchiveManager $manager
|
||||
*/
|
||||
public function setArchiveManager(ArchiveManager $manager)
|
||||
{
|
||||
$this->archiveManager = $manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArchiveManager
|
||||
*/
|
||||
public function getArchiveManager()
|
||||
{
|
||||
return $this->archiveManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Installer\InstallationManager $manager
|
||||
*/
|
||||
|
|
|
@ -360,6 +360,10 @@ class Factory
|
|||
// initialize autoload generator
|
||||
$generator = new AutoloadGenerator($dispatcher, $io);
|
||||
$composer->setAutoloadGenerator($generator);
|
||||
|
||||
// initialize archive manager
|
||||
$am = $this->createArchiveManager($config, $dm);
|
||||
$composer->setArchiveManager($am);
|
||||
}
|
||||
|
||||
// add installers to the manager (must happen after download manager is created since they read it out of $composer)
|
||||
|
|
Loading…
Reference in New Issue