Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101881043
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
Fri, Feb 14, 17:16
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Feb 16, 17:16 (2 d)
Engine
blob
Format
Raw Data
Handle
24246751
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
)
{
$step
=
$this
->
stepMap
[
$node
];
$deps
=
$step
->
getStepImplementation
()->
getDependencies
(
$step
);
$map
[
$node
]
=
array
();
foreach
(
$deps
as
$dep
)
{
$map
[
$node
][]
=
$dep
;
}
}
return
$map
;
}
}
Event Timeline
Log In to Comment