1
0
Fork 0

Merge pull request #4638 from realshadow/configurable_repository

Allows repositories to implement ConfigurableRepositoryInterface
pull/4647/head
Jordi Boggiano 2015-11-26 23:38:03 +00:00
commit 45a3db8877
6 changed files with 60 additions and 5 deletions

View File

@ -20,12 +20,13 @@ use Composer\Package\Loader\LoaderInterface;
/** /**
* @author Serge Smertin <serg.smertin@gmail.com> * @author Serge Smertin <serg.smertin@gmail.com>
*/ */
class ArtifactRepository extends ArrayRepository class ArtifactRepository extends ArrayRepository implements ConfigurableRepositoryInterface
{ {
/** @var LoaderInterface */ /** @var LoaderInterface */
protected $loader; protected $loader;
protected $lookup; protected $lookup;
protected $repoConfig;
public function __construct(array $repoConfig, IOInterface $io) public function __construct(array $repoConfig, IOInterface $io)
{ {
@ -36,6 +37,12 @@ class ArtifactRepository extends ArrayRepository
$this->loader = new ArrayLoader(); $this->loader = new ArrayLoader();
$this->lookup = $repoConfig['url']; $this->lookup = $repoConfig['url'];
$this->io = $io; $this->io = $io;
$this->repoConfig = $repoConfig;
}
public function getRepoConfig()
{
return $this->repoConfig;
} }
protected function initialize() protected function initialize()

View File

@ -31,9 +31,10 @@ use Composer\Semver\Constraint\Constraint;
/** /**
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
*/ */
class ComposerRepository extends ArrayRepository class ComposerRepository extends ArrayRepository implements ConfigurableRepositoryInterface
{ {
protected $config; protected $config;
protected $repoConfig;
protected $options; protected $options;
protected $url; protected $url;
protected $baseUrl; protected $baseUrl;
@ -90,6 +91,12 @@ class ComposerRepository extends ArrayRepository
$this->loader = new ArrayLoader(); $this->loader = new ArrayLoader();
$this->rfs = new RemoteFilesystem($this->io, $this->config, $this->options); $this->rfs = new RemoteFilesystem($this->io, $this->config, $this->options);
$this->eventDispatcher = $eventDispatcher; $this->eventDispatcher = $eventDispatcher;
$this->repoConfig = $repoConfig;
}
public function getRepoConfig()
{
return $this->repoConfig;
} }
public function setRootAliases(array $rootAliases) public function setRootAliases(array $rootAliases)

View File

@ -0,0 +1,23 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Repository;
/**
* Configurable repository interface.
*
* @author Lukas Homza <lukashomz@gmail.com>
*/
interface ConfigurableRepositoryInterface
{
public function getRepoConfig();
}

View File

@ -49,7 +49,7 @@ use Composer\Util\ProcessExecutor;
* @author Samuel Roze <samuel.roze@gmail.com> * @author Samuel Roze <samuel.roze@gmail.com>
* @author Johann Reinke <johann.reinke@gmail.com> * @author Johann Reinke <johann.reinke@gmail.com>
*/ */
class PathRepository extends ArrayRepository class PathRepository extends ArrayRepository implements ConfigurableRepositoryInterface
{ {
/** /**
* @var ArrayLoader * @var ArrayLoader
@ -66,6 +66,11 @@ class PathRepository extends ArrayRepository
*/ */
private $url; private $url;
/**
* @var array
*/
private $repoConfig;
/** /**
* @var ProcessExecutor * @var ProcessExecutor
*/ */
@ -88,10 +93,16 @@ class PathRepository extends ArrayRepository
$this->url = $repoConfig['url']; $this->url = $repoConfig['url'];
$this->process = new ProcessExecutor($io); $this->process = new ProcessExecutor($io);
$this->versionGuesser = new VersionGuesser($config, $this->process, new VersionParser()); $this->versionGuesser = new VersionGuesser($config, $this->process, new VersionParser());
$this->repoConfig = $repoConfig;
parent::__construct(); parent::__construct();
} }
public function getRepoConfig()
{
return $this->repoConfig;
}
/** /**
* Initializes path repository. * Initializes path repository.
* *

View File

@ -32,12 +32,13 @@ use Composer\Config;
* @author Benjamin Eberlei <kontakt@beberlei.de> * @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
*/ */
class PearRepository extends ArrayRepository class PearRepository extends ArrayRepository implements ConfigurableRepositoryInterface
{ {
private $url; private $url;
private $io; private $io;
private $rfs; private $rfs;
private $versionParser; private $versionParser;
private $repoConfig;
/** @var string vendor makes additional alias for each channel as {prefix}/{packagename}. It allows smoother /** @var string vendor makes additional alias for each channel as {prefix}/{packagename}. It allows smoother
* package transition to composer-like repositories. * package transition to composer-like repositories.
@ -60,6 +61,12 @@ class PearRepository extends ArrayRepository
$this->rfs = $rfs ?: new RemoteFilesystem($this->io, $config); $this->rfs = $rfs ?: new RemoteFilesystem($this->io, $config);
$this->vendorAlias = isset($repoConfig['vendor-alias']) ? $repoConfig['vendor-alias'] : null; $this->vendorAlias = isset($repoConfig['vendor-alias']) ? $repoConfig['vendor-alias'] : null;
$this->versionParser = new VersionParser(); $this->versionParser = new VersionParser();
$this->repoConfig = $repoConfig;
}
public function getRepoConfig()
{
return $this->repoConfig;
} }
protected function initialize() protected function initialize()

View File

@ -26,7 +26,7 @@ use Composer\Config;
/** /**
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
*/ */
class VcsRepository extends ArrayRepository class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInterface
{ {
protected $url; protected $url;
protected $packageName; protected $packageName;