3 final class ProjectQueryConduitAPIMethod
extends ProjectConduitAPIMethod
{
5 public function getAPIMethodName() {
6 return 'project.query';
9 public function getMethodDescription() {
10 return pht('Execute searches for Projects.');
13 public function getMethodStatus() {
14 return self
::METHOD_STATUS_FROZEN
;
17 public function getMethodStatusDescription() {
19 'This method is frozen and will eventually be deprecated. New code '.
20 'should use "project.search" instead.');
23 protected function defineParamTypes() {
26 PhabricatorProjectQuery
::STATUS_ANY
,
27 PhabricatorProjectQuery
::STATUS_OPEN
,
28 PhabricatorProjectQuery
::STATUS_CLOSED
,
29 PhabricatorProjectQuery
::STATUS_ACTIVE
,
30 PhabricatorProjectQuery
::STATUS_ARCHIVED
,
33 $status_const = $this->formatStringConstants($statuses);
36 'ids' => 'optional list<int>',
37 'names' => 'optional list<string>',
38 'phids' => 'optional list<phid>',
39 'slugs' => 'optional list<string>',
40 'icons' => 'optional list<string>',
41 'colors' => 'optional list<string>',
42 'status' => 'optional '.$status_const,
44 'members' => 'optional list<phid>',
46 'limit' => 'optional int',
47 'offset' => 'optional int',
51 protected function defineReturnType() {
55 protected function execute(ConduitAPIRequest
$request) {
56 $query = new PhabricatorProjectQuery();
57 $query->setViewer($request->getUser());
58 $query->needMembers(true);
59 $query->needSlugs(true);
61 $ids = $request->getValue('ids');
63 $query->withIDs($ids);
66 $names = $request->getValue('names');
68 $query->withNames($names);
71 $status = $request->getValue('status');
73 $query->withStatus($status);
76 $phids = $request->getValue('phids');
78 $query->withPHIDs($phids);
81 $slugs = $request->getValue('slugs');
83 $query->withSlugs($slugs);
86 $request->getValue('icons');
87 if ($request->getValue('icons')) {
89 $query->withIcons($icons);
92 $colors = $request->getValue('colors');
94 $query->withColors($colors);
97 $members = $request->getValue('members');
99 $query->withMemberPHIDs($members);
102 $limit = $request->getValue('limit');
104 $query->setLimit($limit);
107 $offset = $request->getValue('offset');
109 $query->setOffset($offset);
112 $pager = $this->newPager($request);
113 $results = $query->executeWithCursorPager($pager);
114 $projects = $this->buildProjectInfoDictionaries($results);
116 // TODO: This is pretty hideous.
119 foreach ($slugs as $slug) {
120 $normal = PhabricatorSlug
::normalizeProjectSlug($slug);
121 foreach ($projects as $project) {
122 if (in_array($normal, $project['slugs'])) {
123 $slug_map[$slug] = $project['phid'];
131 'slugMap' => $slug_map,
134 return $this->addPagerResults($result, $pager);