Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/paste/conduit/PasteQueryConduitAPIMethod.php
12241 views
1
<?php
2
3
final class PasteQueryConduitAPIMethod extends PasteConduitAPIMethod {
4
5
public function getAPIMethodName() {
6
return 'paste.query';
7
}
8
9
public function getMethodDescription() {
10
return pht('Query Pastes.');
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 "paste.search" instead.');
21
}
22
23
protected function defineParamTypes() {
24
return array(
25
'ids' => 'optional list<int>',
26
'phids' => 'optional list<phid>',
27
'authorPHIDs' => 'optional list<phid>',
28
'after' => 'optional int',
29
'limit' => 'optional int, default = 100',
30
);
31
}
32
33
protected function defineReturnType() {
34
return 'list<dict>';
35
}
36
37
protected function execute(ConduitAPIRequest $request) {
38
$query = id(new PhabricatorPasteQuery())
39
->setViewer($request->getUser())
40
->needRawContent(true);
41
42
if ($request->getValue('ids')) {
43
$query->withIDs($request->getValue('ids'));
44
}
45
46
if ($request->getValue('phids')) {
47
$query->withPHIDs($request->getValue('phids'));
48
}
49
50
if ($request->getValue('authorPHIDs')) {
51
$query->withAuthorPHIDs($request->getValue('authorPHIDs'));
52
}
53
54
if ($request->getValue('after')) {
55
$query->setAfterID($request->getValue('after'));
56
}
57
58
$limit = $request->getValue('limit', 100);
59
if ($limit) {
60
$query->setLimit($limit);
61
}
62
63
$pastes = $query->execute();
64
65
$results = array();
66
foreach ($pastes as $paste) {
67
$results[$paste->getPHID()] = $this->buildPasteInfoDictionary($paste);
68
}
69
70
return $results;
71
}
72
73
}
74
75