[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/phid/conduit/ -> PHIDLookupConduitAPIMethod.php (source)

   1  <?php
   2  
   3  final class PHIDLookupConduitAPIMethod extends PHIDConduitAPIMethod {
   4  
   5    public function getAPIMethodName() {
   6      return 'phid.lookup';
   7    }
   8  
   9    public function getMethodDescription() {
  10      return 'Look up objects by name.';
  11    }
  12  
  13    public function defineParamTypes() {
  14      return array(
  15        'names' => 'required list<string>',
  16      );
  17    }
  18  
  19    public function defineReturnType() {
  20      return 'nonempty dict<string, wild>';
  21    }
  22  
  23    public function defineErrorTypes() {
  24      return array();
  25    }
  26  
  27    protected function execute(ConduitAPIRequest $request) {
  28      $names = $request->getValue('names');
  29  
  30      $query = id(new PhabricatorObjectQuery())
  31        ->setViewer($request->getUser())
  32        ->withNames($names);
  33      $query->execute();
  34      $name_map = $query->getNamedResults();
  35  
  36      $handles = id(new PhabricatorHandleQuery())
  37        ->setViewer($request->getUser())
  38        ->withPHIDs(mpull($name_map, 'getPHID'))
  39        ->execute();
  40  
  41      $result = array();
  42      foreach ($name_map as $name => $object) {
  43        $phid = $object->getPHID();
  44        $handle = $handles[$phid];
  45        $result[$name] = $this->buildHandleInformationDictionary($handle);
  46      }
  47  
  48      return $result;
  49    }
  50  
  51  }


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