[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/paste/conduit/ -> PasteQueryConduitAPIMethod.php (source)

   1  <?php
   2  
   3  final class PasteQueryConduitAPIMethod extends PasteConduitAPIMethod {
   4  
   5    public function getAPIMethodName() {
   6      return 'paste.query';
   7    }
   8  
   9    public function getMethodDescription() {
  10      return 'Query Pastes.';
  11    }
  12  
  13    public function defineParamTypes() {
  14      return array(
  15        'ids'           => 'optional list<int>',
  16        'phids'         => 'optional list<phid>',
  17        'authorPHIDs'   => 'optional list<phid>',
  18        'after'         => 'optional int',
  19        'limit'         => 'optional int, default = 100',
  20      );
  21    }
  22  
  23    public function defineReturnType() {
  24      return 'list<dict>';
  25    }
  26  
  27    public function defineErrorTypes() {
  28      return array();
  29    }
  30  
  31    protected function execute(ConduitAPIRequest $request) {
  32      $query = id(new PhabricatorPasteQuery())
  33        ->setViewer($request->getUser())
  34        ->needRawContent(true);
  35  
  36      if ($request->getValue('ids')) {
  37        $query->withIDs($request->getValue('ids'));
  38      }
  39  
  40      if ($request->getValue('phids')) {
  41        $query->withPHIDs($request->getValue('phids'));
  42      }
  43  
  44      if ($request->getValue('authorPHIDs')) {
  45        $query->withAuthorPHIDs($request->getValue('authorPHIDs'));
  46      }
  47  
  48      if ($request->getValue('after')) {
  49        $query->setAfterID($request->getValue('after'));
  50      }
  51  
  52      $limit = $request->getValue('limit', 100);
  53      if ($limit) {
  54        $query->setLimit($limit);
  55      }
  56  
  57      $pastes = $query->execute();
  58  
  59      $results = array();
  60      foreach ($pastes as $paste) {
  61        $results[$paste->getPHID()] = $this->buildPasteInfoDictionary($paste);
  62      }
  63  
  64      return $results;
  65    }
  66  
  67  }


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