1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-16 03:42:41 +01:00
phorge-phorge/src/applications/search/controller/PhabricatorSearchHovercardController.php
Bob Trahan b902005bed Kill PhabricatorObjectDataHandle
Summary: Ref T603. Killing this class is cool because the classes that replace it are policy-aware. Tried to keep my wits about me as I did this and fixed a few random things along the way. (Ones I remember right now are pulling a query outside of a foreach loop in Releeph and fixing the text in UIExample to note that the ace of hearts if "a powerful" card and not the "most powerful" card (Q of spades gets that honor IMO))

Test Plan: tested the first few changes (execute, executeOne X handle, object) then got real mechanical / careful with the other changes.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran, FacebookPOC

Maniphest Tasks: T603

Differential Revision: https://secure.phabricator.com/D6941
2013-09-11 12:27:28 -07:00

68 lines
1.6 KiB
PHP

<?php
/**
* @group search
*/
final class PhabricatorSearchHovercardController
extends PhabricatorSearchBaseController {
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(
));
} else {
return id(new AphrontAjaxResponse())->setContent(
array(
'cards' => $cards,
));
}
}
}