Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/flag/conduit/FlagQueryConduitAPIMethod.php
12256 views
1
<?php
2
3
final class FlagQueryConduitAPIMethod extends FlagConduitAPIMethod {
4
5
public function getAPIMethodName() {
6
return 'flag.query';
7
}
8
9
public function getMethodDescription() {
10
return pht('Query flag markers.');
11
}
12
13
protected function defineParamTypes() {
14
return array(
15
'ownerPHIDs' => 'optional list<phid>',
16
'types' => 'optional list<type>',
17
'objectPHIDs' => 'optional list<phid>',
18
19
'offset' => 'optional int',
20
'limit' => 'optional int (default = 100)',
21
);
22
}
23
24
protected function defineReturnType() {
25
return 'list<dict>';
26
}
27
28
protected function execute(ConduitAPIRequest $request) {
29
$query = new PhabricatorFlagQuery();
30
$query->setViewer($request->getUser());
31
32
$owner_phids = $request->getValue('ownerPHIDs', array());
33
if ($owner_phids) {
34
$query->withOwnerPHIDs($owner_phids);
35
}
36
37
$object_phids = $request->getValue('objectPHIDs', array());
38
if ($object_phids) {
39
$query->withObjectPHIDs($object_phids);
40
}
41
42
$types = $request->getValue('types', array());
43
if ($types) {
44
$query->withTypes($types);
45
}
46
47
$query->needHandles(true);
48
49
$query->setOffset($request->getValue('offset', 0));
50
$query->setLimit($request->getValue('limit', 100));
51
52
$flags = $query->execute();
53
54
$results = array();
55
foreach ($flags as $flag) {
56
$results[] = $this->buildFlagInfoDictionary($flag);
57
}
58
59
return $results;
60
}
61
62
}
63
64