Remove product literal strings in "pht()", part 18
[phabricator.git] / src / applications / differential / conduit / DifferentialGetDiffConduitAPIMethod.php
bloba47c9c616b7cbca98ea4824fc6dbcdbd2ab6b295
1 <?php
3 final class DifferentialGetDiffConduitAPIMethod
4 extends DifferentialConduitAPIMethod {
6 public function getAPIMethodName() {
7 return 'differential.getdiff';
10 public function shouldAllowPublic() {
11 return true;
14 public function getMethodStatus() {
15 return self::METHOD_STATUS_DEPRECATED;
18 public function getMethodStatusDescription() {
19 return pht(
20 'This method has been deprecated in favor of %s.',
21 'differential.querydiffs');
25 public function getMethodDescription() {
26 return pht(
27 'Load the content of a diff from Differential by revision ID '.
28 'or diff ID.');
31 protected function defineParamTypes() {
32 return array(
33 'revision_id' => 'optional id',
34 'diff_id' => 'optional id',
38 protected function defineReturnType() {
39 return 'nonempty dict';
42 protected function defineErrorTypes() {
43 return array(
44 'ERR_BAD_DIFF' => pht('No such diff exists.'),
48 protected function execute(ConduitAPIRequest $request) {
49 $diff_id = $request->getValue('diff_id');
51 // If we have a revision ID, we need the most recent diff. Figure that out
52 // without loading all the attached data.
53 $revision_id = $request->getValue('revision_id');
54 if ($revision_id) {
55 $diffs = id(new DifferentialDiffQuery())
56 ->setViewer($request->getUser())
57 ->withRevisionIDs(array($revision_id))
58 ->execute();
59 if ($diffs) {
60 $diff_id = head($diffs)->getID();
61 } else {
62 throw new ConduitException('ERR_BAD_DIFF');
66 $diff = null;
67 if ($diff_id) {
68 $diff = id(new DifferentialDiffQuery())
69 ->setViewer($request->getUser())
70 ->withIDs(array($diff_id))
71 ->needChangesets(true)
72 ->executeOne();
75 if (!$diff) {
76 throw new ConduitException('ERR_BAD_DIFF');
79 return $diff->getDiffDict();