forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhabricatorSearchHovercardController.php
70 lines (57 loc) · 1.64 KB
/
PhabricatorSearchHovercardController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
final class PhabricatorSearchHovercardController
extends PhabricatorSearchBaseController {
public function shouldAllowPublic() {
return true;
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$phids = $request->getArr('phids');
$handles = id(new PhabricatorHandleQuery())
->setViewer($user)
->withPHIDs($phids)
->execute();
$objects = id(new PhabricatorObjectQuery())
->setViewer($user)
->withPHIDs($phids)
->execute();
$cards = array();
foreach ($phids as $phid) {
$handle = $handles[$phid];
$hovercard = new PhabricatorHovercardView();
$hovercard->setObjectHandle($handle);
// 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' => idx($objects, $phid),
));
$event->setUser($user);
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,
));
}
}
}