Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/differential/conduit/DifferentialGetRevisionCommentsConduitAPIMethod.php
12256 views
1
<?php
2
3
final class DifferentialGetRevisionCommentsConduitAPIMethod
4
extends DifferentialConduitAPIMethod {
5
6
public function getAPIMethodName() {
7
return 'differential.getrevisioncomments';
8
}
9
10
public function getMethodStatus() {
11
return self::METHOD_STATUS_DEPRECATED;
12
}
13
14
public function getMethodStatusDescription() {
15
return pht('Obsolete and doomed, see T2222.');
16
}
17
18
public function getMethodDescription() {
19
return pht('Retrieve Differential Revision Comments.');
20
}
21
22
protected function defineParamTypes() {
23
return array(
24
'ids' => 'required list<int>',
25
'inlines' => 'optional bool (deprecated)',
26
);
27
}
28
29
protected function defineReturnType() {
30
return 'nonempty list<dict<string, wild>>';
31
}
32
33
protected function execute(ConduitAPIRequest $request) {
34
$viewer = $request->getUser();
35
$results = array();
36
$revision_ids = $request->getValue('ids');
37
38
if (!$revision_ids) {
39
return $results;
40
}
41
42
$revisions = id(new DifferentialRevisionQuery())
43
->setViewer($viewer)
44
->withIDs($revision_ids)
45
->execute();
46
47
if (!$revisions) {
48
return $results;
49
}
50
51
$xactions = id(new DifferentialTransactionQuery())
52
->setViewer($viewer)
53
->withObjectPHIDs(mpull($revisions, 'getPHID'))
54
->execute();
55
56
$revisions = mpull($revisions, null, 'getPHID');
57
58
foreach ($xactions as $xaction) {
59
$revision = idx($revisions, $xaction->getObjectPHID());
60
if (!$revision) {
61
continue;
62
}
63
64
$type = $xaction->getTransactionType();
65
if ($type == DifferentialTransaction::TYPE_ACTION) {
66
$action = $xaction->getNewValue();
67
} else if ($type == PhabricatorTransactions::TYPE_COMMENT) {
68
$action = 'comment';
69
} else {
70
$action = 'none';
71
}
72
73
$result = array(
74
'revisionID' => $revision->getID(),
75
'action' => $action,
76
'authorPHID' => $xaction->getAuthorPHID(),
77
'dateCreated' => $xaction->getDateCreated(),
78
'content' => ($xaction->hasComment()
79
? $xaction->getComment()->getContent()
80
: null),
81
);
82
83
$results[$revision->getID()][] = $result;
84
}
85
86
return $results;
87
}
88
89
}
90
91