1<?php 2 3final class ArcanistBrowseRevisionURIHardpointQuery 4 extends ArcanistBrowseURIHardpointQuery { 5 6 const BROWSETYPE = 'revision'; 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 $states = array(); 21 $map = array(); 22 foreach ($refs as $key => $ref) { 23 foreach ($ref->getCommitRefs() as $commit_ref) { 24 $hash = $commit_ref->getCommitHash(); 25 $states[$hash] = id(new ArcanistWorkingCopyStateRef()) 26 ->setCommitRef($commit_ref); 27 $map[$hash][] = $key; 28 } 29 } 30 31 if (!$states) { 32 yield $this->yieldMap(array()); 33 } 34 35 yield $this->yieldRequests( 36 $states, 37 array( 38 'revisionRefs', 39 )); 40 41 $results = array(); 42 foreach ($states as $hash => $state) { 43 foreach ($state->getRevisionRefs() as $revision) { 44 if ($revision->isClosed()) { 45 // Don't resolve closed revisions. 46 continue; 47 } 48 49 $uri = $revision->getURI(); 50 51 foreach ($map[$hash] as $key) { 52 $results[$key][] = $this->newBrowseURIRef() 53 ->setURI($uri); 54 } 55 } 56 } 57 58 yield $this->yieldMap($results); 59 } 60 61 62} 63