1<?php
2
3final class ArcanistBrowseCommitURIHardpointQuery
4  extends ArcanistBrowseURIHardpointQuery {
5
6  const BROWSETYPE = 'commit';
7
8  public function loadHardpoint(array $refs, $hardpoint) {
9    $refs = $this->getRefsWithSupportedTypes($refs);
10    if (!$refs) {
11      yield $this->yieldMap(array());
12    }
13
14    yield $this->yieldRequests(
15      $refs,
16      array(
17        ArcanistBrowseRef::HARDPOINT_COMMITREFS,
18      ));
19
20    $commit_refs = array();
21    foreach ($refs as $key => $ref) {
22      foreach ($ref->getCommitRefs() as $commit_ref) {
23        $commit_refs[] = $commit_ref;
24      }
25    }
26
27    yield $this->yieldRequests(
28      $commit_refs,
29      array(
30        ArcanistCommitRef::HARDPOINT_UPSTREAM,
31      ));
32
33    $results = array();
34    foreach ($refs as $key => $ref) {
35      $commit_refs = $ref->getCommitRefs();
36      foreach ($commit_refs as $commit_ref) {
37        $uri = $commit_ref->getURI();
38        if ($uri !== null) {
39          $results[$key][] = $this->newBrowseURIRef()
40            ->setURI($uri);
41        }
42      }
43    }
44
45    yield $this->yieldMap($results);
46  }
47
48
49}
50