Path: blob/master/src/applications/differential/conduit/DifferentialGetDiffConduitAPIMethod.php
12256 views
<?php12final class DifferentialGetDiffConduitAPIMethod3extends DifferentialConduitAPIMethod {45public function getAPIMethodName() {6return 'differential.getdiff';7}89public function shouldAllowPublic() {10return true;11}1213public function getMethodStatus() {14return self::METHOD_STATUS_DEPRECATED;15}1617public function getMethodStatusDescription() {18return pht(19'This method has been deprecated in favor of %s.',20'differential.querydiffs');21}222324public function getMethodDescription() {25return pht(26'Load the content of a diff from Differential by revision ID '.27'or diff ID.');28}2930protected function defineParamTypes() {31return array(32'revision_id' => 'optional id',33'diff_id' => 'optional id',34);35}3637protected function defineReturnType() {38return 'nonempty dict';39}4041protected function defineErrorTypes() {42return array(43'ERR_BAD_DIFF' => pht('No such diff exists.'),44);45}4647protected function execute(ConduitAPIRequest $request) {48$diff_id = $request->getValue('diff_id');4950// If we have a revision ID, we need the most recent diff. Figure that out51// without loading all the attached data.52$revision_id = $request->getValue('revision_id');53if ($revision_id) {54$diffs = id(new DifferentialDiffQuery())55->setViewer($request->getUser())56->withRevisionIDs(array($revision_id))57->execute();58if ($diffs) {59$diff_id = head($diffs)->getID();60} else {61throw new ConduitException('ERR_BAD_DIFF');62}63}6465$diff = null;66if ($diff_id) {67$diff = id(new DifferentialDiffQuery())68->setViewer($request->getUser())69->withIDs(array($diff_id))70->needChangesets(true)71->executeOne();72}7374if (!$diff) {75throw new ConduitException('ERR_BAD_DIFF');76}7778return $diff->getDiffDict();79}8081}828384