[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/maniphest/conduit/ -> ManiphestQueryConduitAPIMethod.php (source)

   1  <?php
   2  
   3  /**
   4   * TODO: Remove maniphest.find, then make this final.
   5   *
   6   * @concrete-extensible
   7   */
   8  class ManiphestQueryConduitAPIMethod extends ManiphestConduitAPIMethod {
   9  
  10    public function getAPIMethodName() {
  11      return 'maniphest.query';
  12    }
  13  
  14    public function getMethodDescription() {
  15      return 'Execute complex searches for Maniphest tasks.';
  16    }
  17  
  18    public function defineParamTypes() {
  19      $statuses = array(
  20        ManiphestTaskQuery::STATUS_ANY,
  21        ManiphestTaskQuery::STATUS_OPEN,
  22        ManiphestTaskQuery::STATUS_CLOSED,
  23        ManiphestTaskQuery::STATUS_RESOLVED,
  24        ManiphestTaskQuery::STATUS_WONTFIX,
  25        ManiphestTaskQuery::STATUS_INVALID,
  26        ManiphestTaskQuery::STATUS_SPITE,
  27        ManiphestTaskQuery::STATUS_DUPLICATE,
  28      );
  29      $status_const = $this->formatStringConstants($statuses);
  30  
  31      $orders = array(
  32        ManiphestTaskQuery::ORDER_PRIORITY,
  33        ManiphestTaskQuery::ORDER_CREATED,
  34        ManiphestTaskQuery::ORDER_MODIFIED,
  35      );
  36      $order_const = $this->formatStringConstants($orders);
  37  
  38      return array(
  39        'ids'               => 'optional list<uint>',
  40        'phids'             => 'optional list<phid>',
  41        'ownerPHIDs'        => 'optional list<phid>',
  42        'authorPHIDs'       => 'optional list<phid>',
  43        'projectPHIDs'      => 'optional list<phid>',
  44        'ccPHIDs'           => 'optional list<phid>',
  45        'fullText'          => 'optional string',
  46  
  47        'status'            => 'optional '.$status_const,
  48        'order'             => 'optional '.$order_const,
  49  
  50        'limit'             => 'optional int',
  51        'offset'            => 'optional int',
  52      );
  53    }
  54  
  55    public function defineReturnType() {
  56      return 'list';
  57    }
  58  
  59    public function defineErrorTypes() {
  60      return array();
  61    }
  62  
  63    protected function execute(ConduitAPIRequest $request) {
  64      $query = new ManiphestTaskQuery();
  65  
  66      $query->setViewer($request->getUser());
  67  
  68      $task_ids = $request->getValue('ids');
  69      if ($task_ids) {
  70        $query->withIDs($task_ids);
  71      }
  72  
  73      $task_phids = $request->getValue('phids');
  74      if ($task_phids) {
  75        $query->withPHIDs($task_phids);
  76      }
  77  
  78      $owners = $request->getValue('ownerPHIDs');
  79      if ($owners) {
  80        $query->withOwners($owners);
  81      }
  82  
  83      $authors = $request->getValue('authorPHIDs');
  84      if ($authors) {
  85        $query->withAuthors($authors);
  86      }
  87  
  88      $projects = $request->getValue('projectPHIDs');
  89      if ($projects) {
  90        $query->withAllProjects($projects);
  91      }
  92  
  93      $ccs = $request->getValue('ccPHIDs');
  94      if ($ccs) {
  95        $query->withSubscribers($ccs);
  96      }
  97  
  98      $full_text = $request->getValue('fullText');
  99      if ($full_text) {
 100        $query->withFullTextSearch($full_text);
 101      }
 102  
 103      $status = $request->getValue('status');
 104      if ($status) {
 105        $query->withStatus($status);
 106      }
 107  
 108      $order = $request->getValue('order');
 109      if ($order) {
 110        $query->setOrderBy($order);
 111      }
 112  
 113      $limit = $request->getValue('limit');
 114      if ($limit) {
 115        $query->setLimit($limit);
 116      }
 117  
 118      $offset = $request->getValue('offset');
 119      if ($offset) {
 120        $query->setOffset($offset);
 121      }
 122  
 123      $results = $query->execute();
 124      return $this->buildTaskInfoDictionaries($results);
 125    }
 126  
 127  }


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