1
0
Fork 0

Pass composer configuration to VcsDriver

pull/617/head
Jerome Tamarelle 2012-04-24 16:56:03 +02:00
parent d489d2aa3c
commit 017ebabcb5
2 changed files with 10 additions and 5 deletions

View File

@ -13,6 +13,7 @@
namespace Composer\Repository\Vcs;
use Composer\Downloader\TransportException;
use Composer\Config;
use Composer\IO\IOInterface;
use Composer\Util\ProcessExecutor;
use Composer\Util\RemoteFilesystem;
@ -26,6 +27,7 @@ abstract class VcsDriver implements VcsDriverInterface
{
protected $url;
protected $io;
protected $config;
protected $process;
protected $remoteFilesystem;
@ -34,13 +36,15 @@ abstract class VcsDriver implements VcsDriverInterface
*
* @param string $url The URL
* @param IOInterface $io The IO instance
* @param Config $config The composer configuration
* @param ProcessExecutor $process Process instance, injectable for mocking
* @param callable $remoteFilesystem Remote Filesystem, injectable for mocking
*/
public function __construct($url, IOInterface $io, ProcessExecutor $process = null, $remoteFilesystem = null)
public function __construct($url, IOInterface $io, Config $config, ProcessExecutor $process = null, $remoteFilesystem = null)
{
$this->url = $url;
$this->io = $io;
$this->config = $config;
$this->process = $process ?: new ProcessExecutor;
$this->remoteFilesystem = $remoteFilesystem ?: new RemoteFilesystem($io);
}
@ -58,7 +62,6 @@ abstract class VcsDriver implements VcsDriverInterface
return false;
}
/**
* Get the https or http protocol depending on SSL support.
*

View File

@ -30,6 +30,7 @@ class VcsRepository extends ArrayRepository
protected $packageName;
protected $verbose;
protected $io;
protected $config;
protected $versionParser;
protected $type;
@ -48,20 +49,21 @@ class VcsRepository extends ArrayRepository
$this->io = $io;
$this->type = isset($repoConfig['type']) ? $repoConfig['type'] : 'vcs';
$this->verbose = $io->isVerbose();
$this->config = $config;
}
public function getDriver()
{
if (isset($this->drivers[$this->type])) {
$class = $this->drivers[$this->type];
$driver = new $class($this->url, $this->io);
$driver = new $class($this->url, $this->io, $this->config);
$driver->initialize();
return $driver;
}
foreach ($this->drivers as $driver) {
if ($driver::supports($this->io, $this->url)) {
$driver = new $driver($this->url, $this->io);
$driver = new $driver($this->url, $this->io, $this->config);
$driver->initialize();
return $driver;
}
@ -69,7 +71,7 @@ class VcsRepository extends ArrayRepository
foreach ($this->drivers as $driver) {
if ($driver::supports($this->io, $this->url, true)) {
$driver = new $driver($this->url, $this->io);
$driver = new $driver($this->url, $this->io, $this->config);
$driver->initialize();
return $driver;
}