Skip to content

Commit

Permalink
added providing require to AssetPackage #14
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Aug 13, 2016
1 parent c8357d5 commit 03c8992
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/models/AssetPackage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Composer\Composer;
use Composer\Factory;
use Composer\IO\NullIO;
use Composer\Package\Link;
use Exception;
use Fxp\Composer\AssetPlugin\Repository\AssetVcsRepository;
use hiqdev\assetpackagist\components\Storage;
Expand Down Expand Up @@ -213,11 +214,15 @@ public function prepareReleases($repository)
$releases = [];
foreach ($repository->getPackages() as $package) {
$version = $package->getVersion();
$require = $this->prepareRequire($package->getRequires());
$release = [
'uid' => $this->prepareUid($version),
'name' => $this->getNormalName(),
'version' => $version,
];
if ($require) {
$release['require'] = $require;
}
if ($package->getDistUrl()) {
$release['dist'] = [
'type' => $package->getDistType(),
Expand All @@ -240,6 +245,21 @@ public function prepareReleases($repository)
return $releases;
}

/**
* Prepares array of requires: name => constraint.
* @param Link[] array of package requires.
* @return array
*/
public function prepareRequire(array $links)
{
$requires = [];
foreach ($links as $name => $link) {
$requires[$name] = $link->getPrettyConstraint();
}

return $requires;
}

public function prepareUid($version)
{
$known = $this->getSaved()->getRelease($version);
Expand Down

0 comments on commit 03c8992

Please sign in to comment.