Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/infrastructure/edges/util/PhabricatorEdgeGraph.php
13422 views
1
<?php
2
3
final class PhabricatorEdgeGraph extends AbstractDirectedGraph {
4
5
private $edgeType;
6
7
public function setEdgeType($edge_type) {
8
$this->edgeType = $edge_type;
9
return $this;
10
}
11
12
protected function loadEdges(array $nodes) {
13
if (!$this->edgeType) {
14
throw new Exception(pht('Set edge type before loading graph!'));
15
}
16
17
$edges = id(new PhabricatorEdgeQuery())
18
->withSourcePHIDs($nodes)
19
->withEdgeTypes(array($this->edgeType))
20
->execute();
21
22
$results = array_fill_keys($nodes, array());
23
foreach ($edges as $src => $types) {
24
foreach ($types as $type => $dsts) {
25
foreach ($dsts as $dst => $edge) {
26
$results[$src][] = $dst;
27
}
28
}
29
}
30
31
return $results;
32
}
33
34
}
35
36