diff --git a/src/Composer/Command/ArchiveCommand.php b/src/Composer/Command/ArchiveCommand.php index 3ca8aaee2..bf64ca47e 100644 --- a/src/Composer/Command/ArchiveCommand.php +++ b/src/Composer/Command/ArchiveCommand.php @@ -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); diff --git a/src/Composer/Composer.php b/src/Composer/Composer.php index c874a0796..a3972f44f 100644 --- a/src/Composer/Composer.php +++ b/src/Composer/Composer.php @@ -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 @@ -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 */ diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index 68e2b8215..a0ca79785 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -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)