From b0151a4ce5f20467333c46dd3dc43560396570bf Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 18 Jul 2012 17:21:21 +0200 Subject: [PATCH] Allow the loader of the VcsRepository to be overriden --- src/Composer/Repository/VcsRepository.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Composer/Repository/VcsRepository.php b/src/Composer/Repository/VcsRepository.php index 8411ab725..641105851 100644 --- a/src/Composer/Repository/VcsRepository.php +++ b/src/Composer/Repository/VcsRepository.php @@ -16,6 +16,7 @@ use Composer\Downloader\TransportException; use Composer\Repository\Vcs\VcsDriverInterface; use Composer\Package\Version\VersionParser; use Composer\Package\Loader\ArrayLoader; +use Composer\Package\Loader\LoaderInterface; use Composer\IO\IOInterface; use Composer\Config; @@ -31,6 +32,7 @@ class VcsRepository extends ArrayRepository protected $config; protected $versionParser; protected $type; + protected $loader; public function __construct(array $repoConfig, IOInterface $io, Config $config, array $drivers = null) { @@ -50,6 +52,11 @@ class VcsRepository extends ArrayRepository $this->config = $config; } + public function setLoader(LoaderInterface $loader) + { + $this->loader = $loader; + } + public function getDriver() { if (isset($this->drivers[$this->type])) { @@ -91,7 +98,9 @@ class VcsRepository extends ArrayRepository } $this->versionParser = new VersionParser; - $loader = new ArrayLoader(); + if (!$this->loader) { + $this->loader = new ArrayLoader($this->versionParser); + } try { if ($driver->hasComposerFile($driver->getRootIdentifier())) { @@ -155,7 +164,7 @@ class VcsRepository extends ArrayRepository $this->io->write('Importing tag '.$tag.' ('.$data['version_normalized'].')'); } - $this->addPackage($loader->load($this->preProcess($driver, $data, $identifier))); + $this->addPackage($this->loader->load($this->preProcess($driver, $data, $identifier))); } catch (\Exception $e) { if ($verbose) { $this->io->write('Skipped tag '.$tag.', '.($e instanceof TransportException ? 'no composer file was found' : $e->getMessage())); @@ -204,7 +213,7 @@ class VcsRepository extends ArrayRepository $this->io->write('Importing branch '.$branch.' ('.$data['version'].')'); } - $this->addPackage($loader->load($this->preProcess($driver, $data, $identifier))); + $this->addPackage($this->loader->load($this->preProcess($driver, $data, $identifier))); } catch (TransportException $e) { if ($verbose) { $this->io->write('Skipped branch '.$branch.', no composer file was found');