yet another github api refactoring
[pharext/pharext.org] / app / Github / API / Repos / ReleasesCallback.php
1 <?php
2
3 namespace app\Github\API\Repos;
4
5 use app\Github\API;
6 use app\Github\API\Callback;
7
8 class ReleasesCallback extends Callback
9 {
10 private $repo;
11
12 function __construct(API $api, $repo) {
13 parent::__construct($api);
14 $this->repo = $repo;
15 }
16
17 function __invoke($json, $links = null) {
18 settype($this->repo->tags, "object");
19 foreach ($json as $release) {
20 $tag = $release->tag_name;
21 settype($this->repo->tags->$tag, "object");
22 $this->repo->tags->$tag->release = $release;
23 $this->api->listReleaseAssets($this->repo->full_name, $release->id, function($assets) use($release) {
24 $release->assets = $assets;
25 });
26 }
27 }
28 }