Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/differential/conduit/DifferentialCloseConduitAPIMethod.php
12256 views
1
<?php
2
3
final class DifferentialCloseConduitAPIMethod
4
extends DifferentialConduitAPIMethod {
5
6
public function getAPIMethodName() {
7
return 'differential.close';
8
}
9
10
public function getMethodDescription() {
11
return pht('Close a Differential revision.');
12
}
13
14
public function getMethodStatus() {
15
return self::METHOD_STATUS_FROZEN;
16
}
17
18
public function getMethodStatusDescription() {
19
return pht(
20
'This method is frozen and will eventually be deprecated. New code '.
21
'should use "differential.revision.edit" instead.');
22
}
23
24
protected function defineParamTypes() {
25
return array(
26
'revisionID' => 'required int',
27
);
28
}
29
30
protected function defineReturnType() {
31
return 'void';
32
}
33
34
protected function defineErrorTypes() {
35
return array(
36
'ERR_NOT_FOUND' => pht('Revision was not found.'),
37
);
38
}
39
40
protected function execute(ConduitAPIRequest $request) {
41
$viewer = $request->getUser();
42
$id = $request->getValue('revisionID');
43
44
$revision = id(new DifferentialRevisionQuery())
45
->withIDs(array($id))
46
->setViewer($viewer)
47
->needReviewers(true)
48
->executeOne();
49
if (!$revision) {
50
throw new ConduitException('ERR_NOT_FOUND');
51
}
52
53
$xactions = array();
54
$xactions[] = id(new DifferentialTransaction())
55
->setTransactionType(
56
DifferentialRevisionCloseTransaction::TRANSACTIONTYPE)
57
->setNewValue(true);
58
59
$content_source = $request->newContentSource();
60
61
$editor = id(new DifferentialTransactionEditor())
62
->setActor($viewer)
63
->setContentSource($request->newContentSource())
64
->setContinueOnMissingFields(true)
65
->setContinueOnNoEffect(true);
66
67
$editor->applyTransactions($revision, $xactions);
68
69
return;
70
}
71
72
}
73
74