[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/search/controller/ -> PhabricatorSearchHovercardController.php (source)

   1  <?php
   2  
   3  final class PhabricatorSearchHovercardController
   4    extends PhabricatorSearchBaseController {
   5  
   6    public function shouldAllowPublic() {
   7      return true;
   8    }
   9  
  10    public function processRequest() {
  11      $request = $this->getRequest();
  12      $user = $request->getUser();
  13  
  14      $phids = $request->getArr('phids');
  15  
  16      $handles = id(new PhabricatorHandleQuery())
  17        ->setViewer($user)
  18        ->withPHIDs($phids)
  19        ->execute();
  20      $objects = id(new PhabricatorObjectQuery())
  21        ->setViewer($user)
  22        ->withPHIDs($phids)
  23        ->execute();
  24  
  25      $cards = array();
  26  
  27      foreach ($phids as $phid) {
  28        $handle = $handles[$phid];
  29  
  30        $hovercard = new PhabricatorHovercardView();
  31        $hovercard->setObjectHandle($handle);
  32  
  33        // Send it to the other side of the world, thanks to PhutilEventEngine
  34        $event = new PhabricatorEvent(
  35          PhabricatorEventType::TYPE_UI_DIDRENDERHOVERCARD,
  36          array(
  37            'hovercard' => $hovercard,
  38            'handle'    => $handle,
  39            'object'    => idx($objects, $phid),
  40          ));
  41        $event->setUser($user);
  42        PhutilEventEngine::dispatchEvent($event);
  43  
  44        $cards[$phid] = $hovercard;
  45      }
  46  
  47      // Browser-friendly for non-Ajax requests
  48      if (!$request->isAjax()) {
  49        foreach ($cards as $key => $hovercard) {
  50          $cards[$key] = phutil_tag('div',
  51            array(
  52              'class' => 'ml',
  53            ),
  54            $hovercard);
  55        }
  56  
  57        return $this->buildApplicationPage(
  58          $cards,
  59          array(
  60            'device' => false,
  61          ));
  62      } else {
  63        return id(new AphrontAjaxResponse())->setContent(
  64          array(
  65            'cards' => $cards,
  66          ));
  67      }
  68    }
  69  
  70  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1