Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F82556899
DifferentialHovercardEngineExtension.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
Thu, Sep 12, 02:38
Size
1 KB
Mime Type
text/x-php
Expires
Sat, Sep 14, 02:38 (2 d)
Engine
blob
Format
Raw Data
Handle
20713481
Attached To
rPH Phabricator
DifferentialHovercardEngineExtension.php
View Options
<?php
final
class
DifferentialHovercardEngineExtension
extends
PhabricatorHovercardEngineExtension
{
const
EXTENSIONKEY
=
'differential'
;
public
function
isExtensionEnabled
()
{
return
PhabricatorApplication
::
isClassInstalled
(
'PhabricatorDifferentialApplication'
);
}
public
function
getExtensionName
()
{
return
pht
(
'Differential Revisions'
);
}
public
function
canRenderObjectHovercard
(
$object
)
{
return
(
$object
instanceof
DifferentialRevision
);
}
public
function
willRenderHovercards
(
array
$objects
)
{
$viewer
=
$this
->
getViewer
();
$phids
=
mpull
(
$objects
,
'getPHID'
);
$revisions
=
id
(
new
DifferentialRevisionQuery
())
->
setViewer
(
$viewer
)
->
withPHIDs
(
$phids
)
->
needReviewers
(
true
)
->
execute
();
$revisions
=
mpull
(
$revisions
,
null
,
'getPHID'
);
return
array
(
'revisions'
=>
$revisions
,
);
}
public
function
renderHovercard
(
PHUIHovercardView
$hovercard
,
PhabricatorObjectHandle
$handle
,
$object
,
$data
)
{
$viewer
=
$this
->
getViewer
();
$revision
=
idx
(
$data
[
'revisions'
],
$object
->
getPHID
());
if
(!
$revision
)
{
return
;
}
$hovercard
->
setTitle
(
'D'
.
$revision
->
getID
());
$hovercard
->
setDetail
(
$revision
->
getTitle
());
$hovercard
->
addField
(
pht
(
'Author'
),
$viewer
->
renderHandle
(
$revision
->
getAuthorPHID
()));
$reviewer_phids
=
$revision
->
getReviewerPHIDs
();
$hovercard
->
addField
(
pht
(
'Reviewers'
),
$viewer
->
renderHandleList
(
$reviewer_phids
)->
setAsInline
(
true
));
$summary
=
$revision
->
getSummary
();
if
(
strlen
(
$summary
))
{
$summary
=
id
(
new
PhutilUTF8StringTruncator
())
->
setMaximumGlyphs
(
120
)
->
truncateString
(
$summary
);
$hovercard
->
addField
(
pht
(
'Summary'
),
$summary
);
}
}
}
Event Timeline
Log In to Comment