1<?php
2
3final class ArcanistBuildBuildplanHardpointQuery
4  extends ArcanistRuntimeHardpointQuery {
5
6  public function getHardpoints() {
7    return array(
8      ArcanistBuildRef::HARDPOINT_BUILDPLANREF,
9    );
10  }
11
12  protected function canLoadRef(ArcanistRef $ref) {
13    return ($ref instanceof ArcanistBuildRef);
14  }
15
16  public function loadHardpoint(array $refs, $hardpoint) {
17    $plan_phids = mpull($refs, 'getBuildPlanPHID');
18    $plan_phids = array_fuse($plan_phids);
19    $plan_phids = array_values($plan_phids);
20
21    $plans = (yield $this->yieldConduitSearch(
22      'harbormaster.buildplan.search',
23      array(
24        'phids' => $plan_phids,
25      )));
26
27    $plan_refs = array();
28    foreach ($plans as $plan) {
29      $plan_ref = ArcanistBuildPlanRef::newFromConduit($plan);
30      $plan_refs[] = $plan_ref;
31    }
32    $plan_refs = mpull($plan_refs, null, 'getPHID');
33
34    $results = array();
35    foreach ($refs as $key => $build_ref) {
36      $plan_phid = $build_ref->getBuildPlanPHID();
37      $plan = idx($plan_refs, $plan_phid);
38      $results[$key] = $plan;
39    }
40
41    yield $this->yieldMap($results);
42  }
43
44}
45