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