[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class ProjectQueryConduitAPIMethod extends ProjectConduitAPIMethod { 4 5 public function getAPIMethodName() { 6 return 'project.query'; 7 } 8 9 public function getMethodDescription() { 10 return 'Execute searches for Projects.'; 11 } 12 13 public function defineParamTypes() { 14 15 $statuses = array( 16 PhabricatorProjectQuery::STATUS_ANY, 17 PhabricatorProjectQuery::STATUS_OPEN, 18 PhabricatorProjectQuery::STATUS_CLOSED, 19 PhabricatorProjectQuery::STATUS_ACTIVE, 20 PhabricatorProjectQuery::STATUS_ARCHIVED, 21 ); 22 23 $status_const = $this->formatStringConstants($statuses); 24 25 return array( 26 'ids' => 'optional list<int>', 27 'names' => 'optional list<string>', 28 'phids' => 'optional list<phid>', 29 'slugs' => 'optional list<string>', 30 'status' => 'optional '.$status_const, 31 32 'members' => 'optional list<phid>', 33 34 'limit' => 'optional int', 35 'offset' => 'optional int', 36 ); 37 } 38 39 public function defineReturnType() { 40 return 'list'; 41 } 42 43 public function defineErrorTypes() { 44 return array(); 45 } 46 47 protected function execute(ConduitAPIRequest $request) { 48 $query = new PhabricatorProjectQuery(); 49 $query->setViewer($request->getUser()); 50 $query->needMembers(true); 51 $query->needSlugs(true); 52 53 $ids = $request->getValue('ids'); 54 if ($ids) { 55 $query->withIDs($ids); 56 } 57 58 $names = $request->getValue('names'); 59 if ($names) { 60 $query->withNames($names); 61 } 62 63 $status = $request->getValue('status'); 64 if ($status) { 65 $query->withStatus($status); 66 } 67 68 $phids = $request->getValue('phids'); 69 if ($phids) { 70 $query->withPHIDs($phids); 71 } 72 73 $slugs = $request->getValue('slugs'); 74 if ($slugs) { 75 $query->withSlugs($slugs); 76 } 77 78 $members = $request->getValue('members'); 79 if ($members) { 80 $query->withMemberPHIDs($members); 81 } 82 83 $limit = $request->getValue('limit'); 84 if ($limit) { 85 $query->setLimit($limit); 86 } 87 88 $offset = $request->getValue('offset'); 89 if ($offset) { 90 $query->setOffset($offset); 91 } 92 93 $pager = $this->newPager($request); 94 $results = $query->executeWithCursorPager($pager); 95 $projects = $this->buildProjectInfoDictionaries($results); 96 97 // TODO: This is pretty hideous. 98 $slug_map = array(); 99 if ($slugs) { 100 foreach ($slugs as $slug) { 101 $normal = rtrim(PhabricatorSlug::normalize($slug), '/'); 102 foreach ($projects as $project) { 103 if (in_array($normal, $project['slugs'])) { 104 $slug_map[$slug] = $project['phid']; 105 } 106 } 107 } 108 } 109 110 $result = array( 111 'data' => $projects, 112 'slugMap' => $slug_map, 113 ); 114 115 return $this->addPagerResults($result, $pager); 116 } 117 118 }
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 |