Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93188392
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
Tue, Nov 26, 21:20
Size
1 KB
Mime Type
text/x-php
Expires
Thu, Nov 28, 21:20 (2 d)
Engine
blob
Format
Raw Data
Handle
22590381
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