1
0
Fork 0

Expose the Driver of the VcsRepository

pull/136/head
Jordi Boggiano 2011-11-27 20:01:56 +01:00
parent 4c7162c94e
commit 9f55335011
1 changed files with 20 additions and 8 deletions

View File

@ -37,20 +37,32 @@ class VcsRepository extends ArrayRepository
$this->debug = $debug; $this->debug = $debug;
} }
public function getDriver()
{
foreach ($this->drivers as $driver) {
if ($driver::supports($this->url)) {
$driver = new $driver($this->url);
$driver->initialize();
return $driver;
}
}
foreach ($this->drivers as $driver) {
if ($driver::supports($this->url, true)) {
$driver = new $driver($this->url);
$driver->initialize();
return $driver;
}
}
}
protected function initialize() protected function initialize()
{ {
parent::initialize(); parent::initialize();
$debug = $this->debug; $debug = $this->debug;
foreach ($this->drivers as $driver) { $driver = $this->getDriver();
if ($driver::supports($this->url)) {
$driver = new $driver($this->url);
$driver->initialize();
break;
}
}
if (!$driver) { if (!$driver) {
throw new \InvalidArgumentException('No driver found to handle VCS repository '.$this->url); throw new \InvalidArgumentException('No driver found to handle VCS repository '.$this->url);
} }