Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/maniphest/conduit/ManiphestQueryConduitAPIMethod.php
12256 views
1
<?php
2
3
final class ManiphestQueryConduitAPIMethod extends ManiphestConduitAPIMethod {
4
5
public function getAPIMethodName() {
6
return 'maniphest.query';
7
}
8
9
public function getMethodDescription() {
10
return pht('Execute complex searches for Maniphest tasks.');
11
}
12
13
public function getMethodStatus() {
14
return self::METHOD_STATUS_FROZEN;
15
}
16
17
public function getMethodStatusDescription() {
18
return pht(
19
'This method is frozen and will eventually be deprecated. New code '.
20
'should use "maniphest.search" instead.');
21
}
22
23
protected function defineParamTypes() {
24
$statuses = array(
25
ManiphestTaskQuery::STATUS_ANY,
26
ManiphestTaskQuery::STATUS_OPEN,
27
ManiphestTaskQuery::STATUS_CLOSED,
28
ManiphestTaskQuery::STATUS_RESOLVED,
29
ManiphestTaskQuery::STATUS_WONTFIX,
30
ManiphestTaskQuery::STATUS_INVALID,
31
ManiphestTaskQuery::STATUS_SPITE,
32
ManiphestTaskQuery::STATUS_DUPLICATE,
33
);
34
$status_const = $this->formatStringConstants($statuses);
35
36
$orders = array(
37
ManiphestTaskQuery::ORDER_PRIORITY,
38
ManiphestTaskQuery::ORDER_CREATED,
39
ManiphestTaskQuery::ORDER_MODIFIED,
40
);
41
$order_const = $this->formatStringConstants($orders);
42
43
return array(
44
'ids' => 'optional list<uint>',
45
'phids' => 'optional list<phid>',
46
'ownerPHIDs' => 'optional list<phid>',
47
'authorPHIDs' => 'optional list<phid>',
48
'projectPHIDs' => 'optional list<phid>',
49
'ccPHIDs' => 'optional list<phid>',
50
'fullText' => 'optional string',
51
52
'status' => 'optional '.$status_const,
53
'order' => 'optional '.$order_const,
54
55
'limit' => 'optional int',
56
'offset' => 'optional int',
57
);
58
}
59
60
protected function defineReturnType() {
61
return 'list';
62
}
63
64
protected function execute(ConduitAPIRequest $request) {
65
$query = id(new ManiphestTaskQuery())
66
->setViewer($request->getUser())
67
->needProjectPHIDs(true)
68
->needSubscriberPHIDs(true);
69
70
$task_ids = $request->getValue('ids');
71
if ($task_ids) {
72
$query->withIDs($task_ids);
73
}
74
75
$task_phids = $request->getValue('phids');
76
if ($task_phids) {
77
$query->withPHIDs($task_phids);
78
}
79
80
$owners = $request->getValue('ownerPHIDs');
81
if ($owners) {
82
$query->withOwners($owners);
83
}
84
85
$authors = $request->getValue('authorPHIDs');
86
if ($authors) {
87
$query->withAuthors($authors);
88
}
89
90
$projects = $request->getValue('projectPHIDs');
91
if ($projects) {
92
$query->withEdgeLogicPHIDs(
93
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
94
PhabricatorQueryConstraint::OPERATOR_AND,
95
$projects);
96
}
97
98
$ccs = $request->getValue('ccPHIDs');
99
if ($ccs) {
100
$query->withSubscribers($ccs);
101
}
102
103
$full_text = $request->getValue('fullText');
104
if ($full_text) {
105
throw new Exception(
106
pht(
107
'Parameter "fullText" is no longer supported. Use method '.
108
'"maniphest.search" with the "query" constraint instead.'));
109
}
110
111
$status = $request->getValue('status');
112
if ($status) {
113
$query->withStatus($status);
114
}
115
116
$order = $request->getValue('order');
117
if ($order) {
118
$query->setOrder($order);
119
}
120
121
$limit = $request->getValue('limit');
122
if ($limit) {
123
$query->setLimit($limit);
124
}
125
126
$offset = $request->getValue('offset');
127
if ($offset) {
128
$query->setOffset($offset);
129
}
130
131
$results = $query->execute();
132
return $this->buildTaskInfoDictionaries($results);
133
}
134
135
}
136
137