Create ArchiveManager with the Factory
parent
d1d77dd13d
commit
60b1cc7d24
|
@ -15,6 +15,7 @@ namespace Composer;
|
|||
use Composer\Config\JsonConfigSource;
|
||||
use Composer\Json\JsonFile;
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Package\Archiver;
|
||||
use Composer\Repository\ComposerRepository;
|
||||
use Composer\Repository\RepositoryManager;
|
||||
use Composer\Util\ProcessExecutor;
|
||||
|
@ -317,6 +318,30 @@ class Factory
|
|||
return $dm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $workDir Directory used to download sources
|
||||
* @param Downloader\DownloadManager $dm Manager use to download sources
|
||||
*
|
||||
* @return Archiver\ArchiveManager
|
||||
*/
|
||||
public function createArchiveManager($workDir = null, DownloadManager $dm = null)
|
||||
{
|
||||
if (null === $dm) {
|
||||
$dm = $this->createDownloadManager(new IO\NullIO());
|
||||
}
|
||||
|
||||
if (null === $workDir) {
|
||||
$workDir = sys_get_temp_dir();
|
||||
}
|
||||
|
||||
$am = new Archiver\ArchiveManager($workDir, $dm);
|
||||
$am->addArchiver(new Archiver\GitArchiver);
|
||||
$am->addArchiver(new Archiver\MercurialArchiver);
|
||||
$am->addArchiver(new Archiver\PharArchiver);
|
||||
|
||||
return $am;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Installer\InstallationManager
|
||||
*/
|
||||
|
|
|
@ -34,16 +34,10 @@ class ArchiveManager
|
|||
* @param string $buildDir The directory used to build the archive
|
||||
* @param DownloadManager $downloadManager A manager used to download package sources
|
||||
*/
|
||||
public function __construct($buildDir, DownloadManager $downloadManager = null)
|
||||
public function __construct($buildDir, DownloadManager $downloadManager)
|
||||
{
|
||||
$this->buildDir = $buildDir;
|
||||
|
||||
if (null !== $downloadManager) {
|
||||
$this->downloadManager = $downloadManager;
|
||||
} else {
|
||||
$factory = new Factory();
|
||||
$this->downloadManager = $factory->createDownloadManager(new NullIO());
|
||||
}
|
||||
$this->downloadManager = $downloadManager;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
namespace Composer\Test\Package\Archiver;
|
||||
|
||||
use Composer\Factory;
|
||||
use Composer\IO\NullIO;
|
||||
use Composer\Package\Archiver;
|
||||
use Composer\Package\Archiver\ArchiveManager;
|
||||
use Composer\Package\PackageInterface;
|
||||
|
@ -30,12 +32,10 @@ class ArchiveManagerTest extends ArchiverTest
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->workDir = sys_get_temp_dir();
|
||||
$factory = new Factory();
|
||||
|
||||
$this->manager = new ArchiveManager($this->workDir);
|
||||
$this->manager->addArchiver(new Archiver\GitArchiver);
|
||||
$this->manager->addArchiver(new Archiver\MercurialArchiver);
|
||||
$this->manager->addArchiver(new Archiver\PharArchiver);
|
||||
$this->workDir = sys_get_temp_dir();
|
||||
$this->manager = $factory->createArchiveManager($this->workDir);
|
||||
}
|
||||
|
||||
public function testUnknownFormat()
|
||||
|
|
Loading…
Reference in New Issue