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