Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F131169
ExampleCustomField.php
All Users
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
epriestley
Mar 18 2014, 2:18 AM
2014-03-18 02:18:44 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
ExampleCustomField.php
View Options
<?php
final
class
ExampleCustomField
extends
ManiphestCustomField
{
public
function
getFieldKey
()
{
return
'example:test'
;
}
public
function
shouldAppearInPropertyView
()
{
return
true
;
}
public
function
renderPropertyViewLabel
()
{
return
pht
(
'Dependency Graph'
);
}
public
function
renderPropertyViewValue
(
array
$handles
)
{
$task
=
$this
->
getObject
();
$edge_type
=
PhabricatorEdgeConfig
::
TYPE_TASK_DEPENDS_ON_TASK
;
$graph
=
id
(
new
PhabricatorEdgeGraph
())
->
setEdgeType
(
$edge_type
)
->
addNodes
(
array
(
'<seed>'
=>
array
(
$task
->
getPHID
()),
))
->
loadGraph
();
$nodes
=
$graph
->
getNodes
();
unset
(
$nodes
[
'<seed>'
]);
if
(
count
(
$nodes
)
==
1
)
{
return
null
;
}
$phids
=
array_keys
(
$nodes
);
$handles
=
id
(
new
PhabricatorHandleQuery
())
->
setViewer
(
$this
->
getViewer
())
->
withPHIDs
(
$phids
)
->
execute
();
return
$this
->
drawNodes
(
$task
->
getPHID
(),
$nodes
,
$handles
,
true
);
}
private
function
drawNodes
(
$phid
,
$nodes
,
$handles
,
$is_top
=
false
)
{
$content
=
array
();
if
(!
$is_top
)
{
$content
[]
=
phutil_tag
(
'li'
,
array
(),
$handles
[
$phid
]->
renderLink
());
}
foreach
(
$nodes
[
$phid
]
as
$other
)
{
$content
[]
=
phutil_tag
(
'li'
,
array
(
'style'
=>
$is_top
?
null
:
'padding-left: 16px;'
,
),
$this
->
drawNodes
(
$other
,
$nodes
,
$handles
));
}
return
phutil_tag
(
'ul'
,
array
(),
$content
);
}
}
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/eb/un/saze77n5ovq7lg2s
Default Alt Text
ExampleCustomField.php (1 KB)
Attached To
Mode
P1094 ExampleCustomField.php
Attached
Detach File
Event Timeline
Log In to Comment