Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/differential/conduit/DifferentialGetRawDiffConduitAPIMethod.php
12256 views
1
<?php
2
3
final class DifferentialGetRawDiffConduitAPIMethod
4
extends DifferentialConduitAPIMethod {
5
6
public function getAPIMethodName() {
7
return 'differential.getrawdiff';
8
}
9
10
public function getMethodDescription() {
11
return pht('Retrieve a raw diff');
12
}
13
14
protected function defineParamTypes() {
15
return array(
16
'diffID' => 'required diffID',
17
);
18
}
19
20
protected function defineReturnType() {
21
return 'nonempty string';
22
}
23
24
protected function defineErrorTypes() {
25
return array(
26
'ERR_NOT_FOUND' => pht('Diff not found.'),
27
);
28
}
29
30
protected function execute(ConduitAPIRequest $request) {
31
$diff_id = $request->getValue('diffID');
32
33
$viewer = $request->getUser();
34
35
$diff = id(new DifferentialDiffQuery())
36
->withIDs(array($diff_id))
37
->setViewer($viewer)
38
->needChangesets(true)
39
->executeOne();
40
41
if (!$diff) {
42
throw new ConduitException('ERR_NOT_FOUND');
43
}
44
45
$renderer = id(new DifferentialRawDiffRenderer())
46
->setChangesets($diff->getChangesets())
47
->setViewer($viewer)
48
->setFormat('git');
49
50
return $renderer->buildPatch();
51
}
52
53
}
54
55