This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Merge pull request #2 from kukulich/composer

Added support for optional pear dependencies in composer repository
  • Loading branch information...
Seldaek committed Apr 8, 2012
2 parents 0da8d9e + 5fa19d7 commit 11304e7ed97882eb4521981266b5d175bf492bbd
Showing with 38 additions and 32 deletions.
  1. +38 −32 pirum
View
70 pirum
@@ -603,43 +603,49 @@ pear install <?php echo $this->server->alias ?>/package_name-beta</code></pre>
}
if (isset($release['deps']) && $deps = @unserialize($release['deps'])) {
- $requirements = isset($deps['required']) ? $deps['required'] : array();
- foreach ($requirements as $reqType => $spec) {
- // wrap single requirements as an array of requirements
- if (isset($spec['name'])) {
- $spec = array($spec);
- }
+ $depsTypes = array(
+ 'required' => 'require',
+ 'optional' => 'suggest',
+ );
+ foreach ($depsTypes as $pearType => $composerType) {
+ $requirements = isset($deps[$pearType]) ? $deps[$pearType] : array();
+ foreach ($requirements as $reqType => $spec) {
+ // wrap single requirements as an array of requirements
+ if (isset($spec['name'])) {
+ $spec = array($spec);
+ }
- if ('php' === $reqType) {
- $version['require']['php'] = $this->createComposerConstraint($spec);
- } elseif ('package' === $reqType) {
- foreach ($spec as $key => $value) {
- if (isset($value['providesextension'])) {
- // skip PECL dependencies
- continue;
- }
- if (isset($value['uri'])) {
- // skip uri-based dependencies
- continue;
- }
+ if ('php' === $reqType) {
+ $version[$composerType]['php'] = $this->createComposerConstraint($spec);
+ } elseif ('package' === $reqType) {
+ foreach ($spec as $key => $value) {
+ if (isset($value['providesextension'])) {
+ // skip PECL dependencies
+ continue;
+ }
+ if (isset($value['uri'])) {
+ // skip uri-based dependencies
+ continue;
+ }
- if (is_array($value)) {
- $dataKey = $value['name'];
- if (false === strpos($dataKey, '/')) {
- $channelUrl = 'http://'.$value['channel'];
- if (!isset($pearChannels[$channelUrl])) {
- $channelInfo = new \SimpleXMLElement($channelUrl.'/channel.xml', null, true);
- $pearChannels[$channelUrl] = ((string) $channelInfo->suggestedalias[0]) ?: (string) $channelInfo->name[0];
+ if (is_array($value)) {
+ $dataKey = $value['name'];
+ if (false === strpos($dataKey, '/')) {
+ $channelUrl = 'http://'.$value['channel'];
+ if (!isset($pearChannels[$channelUrl])) {
+ $channelInfo = new \SimpleXMLElement($channelUrl.'/channel.xml', null, true);
+ $pearChannels[$channelUrl] = ((string) $channelInfo->suggestedalias[0]) ?: (string) $channelInfo->name[0];
+ }
+ $dataKey = $pearChannels[$channelUrl].'/'.$dataKey;
}
- $dataKey = $pearChannels[$channelUrl].'/'.$dataKey;
+ $version[$composerType]['pear-'.$dataKey] = $this->createComposerConstraint($value);
}
- $version['require']['pear-'.$dataKey] = $this->createComposerConstraint($value);
}
- }
- } elseif ('extension' == $reqType) {
- foreach ($spec as $key => $value) {
- $dataKey = 'ext-' . $value['name'];
- $version['require'][$dataKey] = $this->createComposerConstraint($value);
+ } elseif ('extension' == $reqType) {
+ foreach ($spec as $key => $value) {
+ $dataKey = 'ext-' . $value['name'];
+ $version[$composerType][$dataKey] = $this->createComposerConstraint($value);
+ }
}
}
}

0 comments on commit 11304e7

Please sign in to comment.