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

View File

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