From 5b748eda6cc87501aefeff3692ba9ffc077422dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Homza?= Date: Mon, 23 Nov 2015 23:18:24 +0100 Subject: [PATCH] Allows repositories to implement ConfigurableRepositoryInterface and thus provide getRepoConfigmethod --- .../Repository/ArtifactRepository.php | 9 +++++++- .../Repository/ComposerRepository.php | 9 +++++++- .../ConfigurableRepositoryInterface.php | 23 +++++++++++++++++++ src/Composer/Repository/PathRepository.php | 13 ++++++++++- src/Composer/Repository/PearRepository.php | 9 +++++++- src/Composer/Repository/VcsRepository.php | 2 +- 6 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 src/Composer/Repository/ConfigurableRepositoryInterface.php diff --git a/src/Composer/Repository/ArtifactRepository.php b/src/Composer/Repository/ArtifactRepository.php index 01d662212..81335ef7e 100644 --- a/src/Composer/Repository/ArtifactRepository.php +++ b/src/Composer/Repository/ArtifactRepository.php @@ -20,12 +20,13 @@ use Composer\Package\Loader\LoaderInterface; /** * @author Serge Smertin */ -class ArtifactRepository extends ArrayRepository +class ArtifactRepository extends ArrayRepository implements ConfigurableRepositoryInterface { /** @var LoaderInterface */ protected $loader; protected $lookup; + protected $repoConfig; public function __construct(array $repoConfig, IOInterface $io) { @@ -36,6 +37,12 @@ class ArtifactRepository extends ArrayRepository $this->loader = new ArrayLoader(); $this->lookup = $repoConfig['url']; $this->io = $io; + $this->repoConfig = $repoConfig; + } + + public function getRepoConfig() + { + return $this->repoConfig; } protected function initialize() diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index ce73037a8..acfe10b0d 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -31,9 +31,10 @@ use Composer\Semver\Constraint\Constraint; /** * @author Jordi Boggiano */ -class ComposerRepository extends ArrayRepository +class ComposerRepository extends ArrayRepository implements ConfigurableRepositoryInterface { protected $config; + protected $repoConfig; protected $options; protected $url; protected $baseUrl; @@ -90,6 +91,12 @@ class ComposerRepository extends ArrayRepository $this->loader = new ArrayLoader(); $this->rfs = new RemoteFilesystem($this->io, $this->config, $this->options); $this->eventDispatcher = $eventDispatcher; + $this->repoConfig = $repoConfig; + } + + public function getRepoConfig() + { + return $this->repoConfig; } public function setRootAliases(array $rootAliases) diff --git a/src/Composer/Repository/ConfigurableRepositoryInterface.php b/src/Composer/Repository/ConfigurableRepositoryInterface.php new file mode 100644 index 000000000..ff202dc88 --- /dev/null +++ b/src/Composer/Repository/ConfigurableRepositoryInterface.php @@ -0,0 +1,23 @@ + + * Jordi Boggiano + * + * 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 + */ +interface ConfigurableRepositoryInterface +{ + public function getRepoConfig(); +} diff --git a/src/Composer/Repository/PathRepository.php b/src/Composer/Repository/PathRepository.php index ad6b2c6a3..b826ca999 100644 --- a/src/Composer/Repository/PathRepository.php +++ b/src/Composer/Repository/PathRepository.php @@ -49,7 +49,7 @@ use Composer\Util\ProcessExecutor; * @author Samuel Roze * @author Johann Reinke */ -class PathRepository extends ArrayRepository +class PathRepository extends ArrayRepository implements ConfigurableRepositoryInterface { /** * @var ArrayLoader @@ -66,6 +66,11 @@ class PathRepository extends ArrayRepository */ private $url; + /** + * @var array + */ + private $repoConfig; + /** * @var ProcessExecutor */ @@ -88,10 +93,16 @@ class PathRepository extends ArrayRepository $this->url = $repoConfig['url']; $this->process = new ProcessExecutor($io); $this->versionGuesser = new VersionGuesser($config, $this->process, new VersionParser()); + $this->repoConfig = $repoConfig; parent::__construct(); } + public function getRepoConfig() + { + return $this->repoConfig; + } + /** * Initializes path repository. * diff --git a/src/Composer/Repository/PearRepository.php b/src/Composer/Repository/PearRepository.php index e2519d9b9..3ce268bde 100644 --- a/src/Composer/Repository/PearRepository.php +++ b/src/Composer/Repository/PearRepository.php @@ -32,12 +32,13 @@ use Composer\Config; * @author Benjamin Eberlei * @author Jordi Boggiano */ -class PearRepository extends ArrayRepository +class PearRepository extends ArrayRepository implements ConfigurableRepositoryInterface { private $url; private $io; private $rfs; private $versionParser; + private $repoConfig; /** @var string vendor makes additional alias for each channel as {prefix}/{packagename}. It allows smoother * package transition to composer-like repositories. @@ -60,6 +61,12 @@ class PearRepository extends ArrayRepository $this->rfs = $rfs ?: new RemoteFilesystem($this->io, $config); $this->vendorAlias = isset($repoConfig['vendor-alias']) ? $repoConfig['vendor-alias'] : null; $this->versionParser = new VersionParser(); + $this->repoConfig = $repoConfig; + } + + public function getRepoConfig() + { + return $this->repoConfig; } protected function initialize() diff --git a/src/Composer/Repository/VcsRepository.php b/src/Composer/Repository/VcsRepository.php index 16ffa3147..cc819e694 100644 --- a/src/Composer/Repository/VcsRepository.php +++ b/src/Composer/Repository/VcsRepository.php @@ -26,7 +26,7 @@ use Composer\Config; /** * @author Jordi Boggiano */ -class VcsRepository extends ArrayRepository +class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInterface { protected $url; protected $packageName;