[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/releeph/conduit/ -> ReleephQueryBranchesConduitAPIMethod.php (source)

   1  <?php
   2  
   3  final class ReleephQueryBranchesConduitAPIMethod
   4    extends ReleephConduitAPIMethod {
   5  
   6    public function getAPIMethodName() {
   7      return 'releeph.querybranches';
   8    }
   9  
  10    public function getMethodDescription() {
  11      return pht('Query information about Releeph branches.');
  12    }
  13  
  14    public function defineParamTypes() {
  15      return array(
  16        'ids' => 'optional list<id>',
  17        'phids' => 'optional list<phid>',
  18        'productPHIDs' => 'optional list<phid>',
  19      ) + $this->getPagerParamTypes();
  20    }
  21  
  22    public function defineReturnType() {
  23      return 'query-results';
  24    }
  25  
  26    public function defineErrorTypes() {
  27      return array();
  28    }
  29  
  30    protected function execute(ConduitAPIRequest $request) {
  31      $viewer = $request->getUser();
  32  
  33      $query = id(new ReleephBranchQuery())
  34        ->setViewer($viewer);
  35  
  36      $ids = $request->getValue('ids');
  37      if ($ids !== null) {
  38        $query->withIDs($ids);
  39      }
  40  
  41      $phids = $request->getValue('phids');
  42      if ($phids !== null) {
  43        $query->withPHIDs($phids);
  44      }
  45  
  46      $product_phids = $request->getValue('productPHIDs');
  47      if ($product_phids !== null) {
  48        $query->withProductPHIDs($product_phids);
  49      }
  50  
  51      $pager = $this->newPager($request);
  52      $branches = $query->executeWithCursorPager($pager);
  53  
  54      $data = array();
  55      foreach ($branches as $branch) {
  56        $id = $branch->getID();
  57  
  58        $uri = '/releeph/branch/'.$id.'/';
  59        $uri = PhabricatorEnv::getProductionURI($uri);
  60  
  61        $data[] = array(
  62          'id' => $id,
  63          'phid' => $branch->getPHID(),
  64          'uri' => $uri,
  65          'name' => $branch->getName(),
  66          'productPHID' => $branch->getProduct()->getPHID(),
  67        );
  68      }
  69  
  70      return $this->addPagerResults(
  71        array(
  72          'data' => $data,
  73        ),
  74        $pager);
  75    }
  76  
  77  }


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