[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/phame/conduit/ -> PhameQueryConduitAPIMethod.php (source)

   1  <?php
   2  
   3  final class PhameQueryConduitAPIMethod extends PhameConduitAPIMethod {
   4  
   5    public function getAPIMethodName() {
   6      return 'phame.query';
   7    }
   8  
   9    public function getMethodDescription() {
  10      return 'Query phame blogs.';
  11    }
  12  
  13    public function getMethodStatus() {
  14      return self::METHOD_STATUS_UNSTABLE;
  15    }
  16  
  17    public function defineParamTypes() {
  18      return array(
  19        'ids'           => 'optional list<int>',
  20        'phids'         => 'optional list<phid>',
  21        'after'         => 'optional int',
  22        'before'        => 'optional int',
  23        'limit'         => 'optional int',
  24      );
  25    }
  26  
  27    public function defineReturnType() {
  28      return 'list<dict>';
  29    }
  30  
  31    public function defineErrorTypes() {
  32      return array();
  33    }
  34  
  35    protected function execute(ConduitAPIRequest $request) {
  36      $query = new PhameBlogQuery();
  37  
  38      $query->setViewer($request->getUser());
  39  
  40      $ids = $request->getValue('ids', array());
  41      if ($ids) {
  42        $query->withIDs($ids);
  43      }
  44  
  45      $phids = $request->getValue('phids', array());
  46      if ($phids) {
  47        $query->withPHIDs($phids);
  48      }
  49  
  50      $after = $request->getValue('after', null);
  51      if ($after !== null) {
  52        $query->setAfterID($after);
  53      }
  54  
  55      $before = $request->getValue('before', null);
  56      if ($before !== null) {
  57        $query->setBeforeID($before);
  58      }
  59  
  60      $limit = $request->getValue('limit', null);
  61      if ($limit !== null) {
  62        $query->setLimit($limit);
  63      }
  64  
  65      $blogs = $query->execute();
  66  
  67      $results = array();
  68      foreach ($blogs as $blog) {
  69        $results[] = array(
  70          'id'              => $blog->getID(),
  71          'phid'            => $blog->getPHID(),
  72          'name'            => $blog->getName(),
  73          'description'     => $blog->getDescription(),
  74          'domain'          => $blog->getDomain(),
  75          'creatorPHID'     => $blog->getCreatorPHID(),
  76        );
  77      }
  78  
  79      return $results;
  80    }
  81  
  82  }


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