Remove product literal strings in "pht()", part 6
[phabricator.git] / src / applications / project / conduit / ProjectQueryConduitAPIMethod.php
blob0a02088413be20db441e9261a9fffb01c2115283
1 <?php
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() {
18 return pht(
19 'This method is frozen and will eventually be deprecated. New code '.
20 'should use "project.search" instead.');
23 protected function defineParamTypes() {
25 $statuses = array(
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);
35 return array(
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() {
52 return 'list';
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');
62 if ($ids) {
63 $query->withIDs($ids);
66 $names = $request->getValue('names');
67 if ($names) {
68 $query->withNames($names);
71 $status = $request->getValue('status');
72 if ($status) {
73 $query->withStatus($status);
76 $phids = $request->getValue('phids');
77 if ($phids) {
78 $query->withPHIDs($phids);
81 $slugs = $request->getValue('slugs');
82 if ($slugs) {
83 $query->withSlugs($slugs);
86 $request->getValue('icons');
87 if ($request->getValue('icons')) {
88 $icons = array();
89 $query->withIcons($icons);
92 $colors = $request->getValue('colors');
93 if ($colors) {
94 $query->withColors($colors);
97 $members = $request->getValue('members');
98 if ($members) {
99 $query->withMemberPHIDs($members);
102 $limit = $request->getValue('limit');
103 if ($limit) {
104 $query->setLimit($limit);
107 $offset = $request->getValue('offset');
108 if ($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.
117 $slug_map = array();
118 if ($slugs) {
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'];
129 $result = array(
130 'data' => $projects,
131 'slugMap' => $slug_map,
134 return $this->addPagerResults($result, $pager);