Remove product literal strings in "pht()", part 6
[phabricator.git] / src / applications / harbormaster / engine / HarbormasterBuildGraph.php
blob64c12c2e8f50f6667b3f80d514e80e10f6c55d44
1 <?php
3 /**
4 * Directed graph representing a build plan
5 */
6 final class HarbormasterBuildGraph extends AbstractDirectedGraph {
8 private $stepMap;
10 public static function determineDependencyExecution(
11 HarbormasterBuildPlan $plan) {
13 $steps = id(new HarbormasterBuildStepQuery())
14 ->setViewer(PhabricatorUser::getOmnipotentUser())
15 ->withBuildPlanPHIDs(array($plan->getPHID()))
16 ->execute();
18 $steps_by_phid = mpull($steps, null, 'getPHID');
19 $step_phids = mpull($steps, 'getPHID');
21 if (count($steps) === 0) {
22 return array();
25 $graph = id(new HarbormasterBuildGraph($steps_by_phid))
26 ->addNodes($step_phids);
28 $raw_results = $graph->getNodesInRoughTopologicalOrder();
30 $results = array();
31 foreach ($raw_results as $node) {
32 $results[] = array(
33 'node' => $steps_by_phid[$node['node']],
34 'depth' => $node['depth'],
35 'cycle' => $node['cycle'],
39 return $results;
42 public function __construct($step_map) {
43 $this->stepMap = $step_map;
46 protected function loadEdges(array $nodes) {
47 $map = array();
48 foreach ($nodes as $node) {
49 $step = $this->stepMap[$node];
51 try {
52 $deps = $step->getStepImplementation()->getDependencies($step);
53 } catch (Exception $ex) {
54 $deps = array();
57 $map[$node] = array();
58 foreach ($deps as $dep) {
59 $map[$node][] = $dep;
63 return $map;