[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class DifferentialGetDiffConduitAPIMethod 4 extends DifferentialConduitAPIMethod { 5 6 public function getAPIMethodName() { 7 return 'differential.getdiff'; 8 } 9 10 public function shouldAllowPublic() { 11 return true; 12 } 13 14 public function getMethodStatus() { 15 return self::METHOD_STATUS_DEPRECATED; 16 } 17 18 public function getMethodStatusDescription() { 19 return pht( 20 'This method has been deprecated in favor of differential.querydiffs.'); 21 } 22 23 24 public function getMethodDescription() { 25 return pht('Load the content of a diff from Differential by revision id '. 26 'or diff id.'); 27 } 28 29 public function defineParamTypes() { 30 return array( 31 'revision_id' => 'optional id', 32 'diff_id' => 'optional id', 33 ); 34 } 35 36 public function defineReturnType() { 37 return 'nonempty dict'; 38 } 39 40 public function defineErrorTypes() { 41 return array( 42 'ERR_BAD_DIFF' => 'No such diff exists.', 43 ); 44 } 45 46 protected function execute(ConduitAPIRequest $request) { 47 $diff_id = $request->getValue('diff_id'); 48 49 // If we have a revision ID, we need the most recent diff. Figure that out 50 // without loading all the attached data. 51 $revision_id = $request->getValue('revision_id'); 52 if ($revision_id) { 53 $diffs = id(new DifferentialDiffQuery()) 54 ->setViewer($request->getUser()) 55 ->withRevisionIDs(array($revision_id)) 56 ->execute(); 57 if ($diffs) { 58 $diff_id = head($diffs)->getID(); 59 } else { 60 throw new ConduitException('ERR_BAD_DIFF'); 61 } 62 } 63 64 $diff = null; 65 if ($diff_id) { 66 $diff = id(new DifferentialDiffQuery()) 67 ->setViewer($request->getUser()) 68 ->withIDs(array($diff_id)) 69 ->needChangesets(true) 70 ->needArcanistProjects(true) 71 ->executeOne(); 72 } 73 74 if (!$diff) { 75 throw new ConduitException('ERR_BAD_DIFF'); 76 } 77 78 return $diff->getDiffDict(); 79 } 80 81 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |