[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class ReleephQueryProductsConduitAPIMethod 4 extends ReleephConduitAPIMethod { 5 6 public function getAPIMethodName() { 7 return 'releeph.queryproducts'; 8 } 9 10 public function getMethodDescription() { 11 return pht('Query information about Releeph products.'); 12 } 13 14 public function defineParamTypes() { 15 return array( 16 'ids' => 'optional list<id>', 17 'phids' => 'optional list<phid>', 18 'repositoryPHIDs' => 'optional list<phid>', 19 'isActive' => 'optional bool', 20 ) + $this->getPagerParamTypes(); 21 } 22 23 public function defineReturnType() { 24 return 'query-results'; 25 } 26 27 public function defineErrorTypes() { 28 return array(); 29 } 30 31 protected function execute(ConduitAPIRequest $request) { 32 $viewer = $request->getUser(); 33 34 $query = id(new ReleephProductQuery()) 35 ->setViewer($viewer); 36 37 $ids = $request->getValue('ids'); 38 if ($ids !== null) { 39 $query->withIDs($ids); 40 } 41 42 $phids = $request->getValue('phids'); 43 if ($phids !== null) { 44 $query->withPHIDs($phids); 45 } 46 47 $repository_phids = $request->getValue('repositoryPHIDs'); 48 if ($repository_phids !== null) { 49 $query->withRepositoryPHIDs($repository_phids); 50 } 51 52 $is_active = $request->getValue('isActive'); 53 if ($is_active !== null) { 54 $query->withActive($is_active); 55 } 56 57 $pager = $this->newPager($request); 58 $products = $query->executeWithCursorPager($pager); 59 60 $data = array(); 61 foreach ($products as $product) { 62 $id = $product->getID(); 63 64 $uri = '/releeph/product/'.$id.'/'; 65 $uri = PhabricatorEnv::getProductionURI($uri); 66 67 $data[] = array( 68 'id' => $id, 69 'phid' => $product->getPHID(), 70 'uri' => $uri, 71 'name' => $product->getName(), 72 'isActive' => (bool)$product->getIsActive(), 73 'repositoryPHID' => $product->getRepositoryPHID(), 74 ); 75 } 76 77 return $this->addPagerResults( 78 array( 79 'data' => $data, 80 ), 81 $pager); 82 } 83 84 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |