Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90913040
PhabricatorSearchHovercardController.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 5, 22:38
Size
1 KB
Mime Type
text/x-php
Expires
Thu, Nov 7, 22:38 (2 d)
Engine
blob
Format
Raw Data
Handle
22156190
Attached To
rPH Phabricator
PhabricatorSearchHovercardController.php
View Options
<?php
final
class
PhabricatorSearchHovercardController
extends
PhabricatorSearchBaseController
{
public
function
shouldAllowPublic
()
{
return
true
;
}
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$this
->
getViewer
();
$phids
=
$request
->
getArr
(
'phids'
);
$handles
=
id
(
new
PhabricatorHandleQuery
())
->
setViewer
(
$viewer
)
->
withPHIDs
(
$phids
)
->
execute
();
$objects
=
id
(
new
PhabricatorObjectQuery
())
->
setViewer
(
$viewer
)
->
withPHIDs
(
$phids
)
->
execute
();
$cards
=
array
();
foreach
(
$phids
as
$phid
)
{
$handle
=
$handles
[
$phid
];
$object
=
$objects
[
$phid
];
$hovercard
=
id
(
new
PhabricatorHovercardView
())
->
setUser
(
$viewer
)
->
setObjectHandle
(
$handle
);
if
(
$object
)
{
$hovercard
->
setObject
(
$object
);
}
// Send it to the other side of the world, thanks to PhutilEventEngine
$event
=
new
PhabricatorEvent
(
PhabricatorEventType
::
TYPE_UI_DIDRENDERHOVERCARD
,
array
(
'hovercard'
=>
$hovercard
,
'handle'
=>
$handle
,
'object'
=>
$object
,
));
$event
->
setUser
(
$viewer
);
PhutilEventEngine
::
dispatchEvent
(
$event
);
$cards
[
$phid
]
=
$hovercard
;
}
// Browser-friendly for non-Ajax requests
if
(!
$request
->
isAjax
())
{
foreach
(
$cards
as
$key
=>
$hovercard
)
{
$cards
[
$key
]
=
phutil_tag
(
'div'
,
array
(
'class'
=>
'ml'
,
),
$hovercard
);
}
return
$this
->
buildApplicationPage
(
$cards
,
array
(
'device'
=>
false
,
));
}
else
{
return
id
(
new
AphrontAjaxResponse
())->
setContent
(
array
(
'cards'
=>
$cards
,
));
}
}
}
Event Timeline
Log In to Comment