Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F98220639
HarbormasterBuildGraph.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Jan 11, 04:42
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Jan 13, 04:42 (2 d)
Engine
blob
Format
Raw Data
Handle
23534770
Attached To
rPH Phabricator
HarbormasterBuildGraph.php
View Options
<?php
/**
* Directed graph representing a build plan
*/
final
class
HarbormasterBuildGraph
extends
AbstractDirectedGraph
{
private
$stepMap
;
public
static
function
determineDependencyExecution
(
HarbormasterBuildPlan
$plan
)
{
$steps
=
id
(
new
HarbormasterBuildStepQuery
())
->
setViewer
(
PhabricatorUser
::
getOmnipotentUser
())
->
withBuildPlanPHIDs
(
array
(
$plan
->
getPHID
()))
->
execute
();
$steps_by_phid
=
mpull
(
$steps
,
null
,
'getPHID'
);
$step_phids
=
mpull
(
$steps
,
'getPHID'
);
if
(
count
(
$steps
)
===
0
)
{
return
array
();
}
$graph
=
id
(
new
HarbormasterBuildGraph
(
$steps_by_phid
))
->
addNodes
(
$step_phids
);
$raw_results
=
$graph
->
getBestEffortTopographicallySortedNodes
();
$results
=
array
();
foreach
(
$raw_results
as
$node
)
{
$results
[]
=
array
(
'node'
=>
$steps_by_phid
[
$node
[
'node'
]],
'depth'
=>
$node
[
'depth'
],
'cycle'
=>
$node
[
'cycle'
]);
}
return
$results
;
}
public
function
__construct
(
$step_map
)
{
$this
->
stepMap
=
$step_map
;
}
protected
function
loadEdges
(
array
$nodes
)
{
$map
=
array
();
foreach
(
$nodes
as
$node
)
{
$deps
=
$this
->
stepMap
[
$node
]->
getDetail
(
'dependsOn'
,
array
());
$map
[
$node
]
=
array
();
foreach
(
$deps
as
$dep
)
{
$map
[
$node
][]
=
$dep
;
}
}
return
$map
;
}
}
Event Timeline
Log In to Comment