Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add support for the new composer repository format

  • Loading branch information...
commit a476d1f97dcd88bfb3c9fec44a72fe2e15151c2c 1 parent b14366e
@Seldaek Seldaek authored
Showing with 28 additions and 11 deletions.
  1. +28 −11 src/Composer/Repository/ComposerRepository.php
View
39 src/Composer/Repository/ComposerRepository.php
@@ -45,21 +45,38 @@ public function __construct(array $config, IOInterface $io)
protected function initialize()
{
parent::initialize();
- $json = new JsonFile($this->url.'/packages.json', new RemoteFilesystem($this->io));
- $packages = $json->read();
- if (!$packages) {
- throw new \UnexpectedValueException('Could not parse package list from the '.$this->url.' repository');
+ $json = new JsonFile($this->url.'/packages.json', new RemoteFilesystem($this->io));
+ $data = $json->read();
+
+ $loader = new ArrayLoader();
+ $this->loadRepository($loader, $data);
+ }
+
+ protected function loadRepository(ArrayLoader $loader, $data)
+ {
+ // legacy repo handling
+ if (!isset($data['packages']) && !isset($data['includes'])) {
+ foreach ($data as $pkg) {
+ foreach ($pkg['versions'] as $metadata) {
+ $this->addPackage($loader->load($metadata));
+ }
+ }
+
+ return;
}
- if (isset($packages['includes'])) {
- $this->io->write('<error>Your version of composer is too old, please run `php composer.phar self-update` to update it.</error>');
- exit(1);
+ if (isset($data['packages'])) {
+ foreach ($data['packages'] as $package => $versions) {
+ foreach ($versions as $version => $metadata) {
+ $this->addPackage($loader->load($metadata));
+ }
+ }
}
- $loader = new ArrayLoader();
- foreach ($packages as $data) {
- foreach ($data['versions'] as $rev) {
- $this->addPackage($loader->load($rev));
+ if (isset($data['includes'])) {
+ foreach ($data['includes'] as $include => $metadata) {
+ $json = new JsonFile($this->url.'/'.$include, new RemoteFilesystem($this->io));
+ $this->loadRepository($loader, $json->read());
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.