From 4fdc60203748e2217127ab66625776cbc3793f83 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 20 Nov 2011 21:23:50 +0100 Subject: [PATCH] Make VcsRepository drivers configurable --- src/Composer/Repository/VcsRepository.php | 30 ++++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/Composer/Repository/VcsRepository.php b/src/Composer/Repository/VcsRepository.php index 481701d86..2d56efec6 100644 --- a/src/Composer/Repository/VcsRepository.php +++ b/src/Composer/Repository/VcsRepository.php @@ -13,23 +13,15 @@ class VcsRepository extends ArrayRepository { protected $url; protected $packageName; + protected $debug; - public function __construct(array $config) + public function __construct(array $config, array $drivers = null) { if (!filter_var($config['url'], FILTER_VALIDATE_URL)) { throw new \UnexpectedValueException('Invalid url given for PEAR repository: '.$config['url']); } - $this->url = $config['url']; - } - - protected function initialize() - { - parent::initialize(); - - $debug = false; - - $drivers = array( + $this->drivers = $drivers ?: array( 'Composer\Repository\Vcs\GitHubDriver', 'Composer\Repository\Vcs\GitBitbucketDriver', 'Composer\Repository\Vcs\GitDriver', @@ -37,7 +29,21 @@ class VcsRepository extends ArrayRepository 'Composer\Repository\Vcs\HgDriver', ); - foreach ($drivers as $driver) { + $this->url = $config['url']; + } + + public function setDebug($debug) + { + $this->debug = $debug; + } + + protected function initialize() + { + parent::initialize(); + + $debug = $this->debug; + + foreach ($this->drivers as $driver) { if ($driver::supports($this->url)) { $driver = new $driver($this->url); $driver->initialize();