mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-11 09:22:40 +01:00
023dee0d3b
Summary: Ref T5655. Rename Conduit classes and provide a `getAPIMethodName` method to declare the API method. Test Plan: ``` > echo '{}' | arc --conduit-uri='http://phabricator.joshuaspence.com' call-conduit user.whoami Waiting for JSON parameters on stdin... {"error":null,"errorMessage":null,"response":{"phid":"PHID-USER-lioqffnwn6y475mu5ndb","userName":"josh","realName":"Joshua Spence","image":"http:\/\/phabricator.joshuaspence.com\/res\/1404425321T\/phabricator\/3eb28cd9\/rsrc\/image\/avatar.png","uri":"http:\/\/phabricator.joshuaspence.com\/p\/josh\/","roles":["admin","verified","approved","activated"]}} ``` Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin, hach-que Maniphest Tasks: T5655 Differential Revision: https://secure.phabricator.com/D9991
103 lines
2.8 KiB
PHP
103 lines
2.8 KiB
PHP
<?php
|
|
|
|
final class DifferentialGetRevisionConduitAPIMethod
|
|
extends DifferentialConduitAPIMethod {
|
|
|
|
public function getAPIMethodName() {
|
|
return 'differential.getrevision';
|
|
}
|
|
|
|
public function getMethodStatus() {
|
|
return self::METHOD_STATUS_DEPRECATED;
|
|
}
|
|
|
|
public function getMethodStatusDescription() {
|
|
return "Replaced by 'differential.query'.";
|
|
}
|
|
|
|
public function getMethodDescription() {
|
|
return 'Load the content of a revision from Differential.';
|
|
}
|
|
|
|
public function defineParamTypes() {
|
|
return array(
|
|
'revision_id' => 'required id',
|
|
);
|
|
}
|
|
|
|
public function defineReturnType() {
|
|
return 'nonempty dict';
|
|
}
|
|
|
|
public function defineErrorTypes() {
|
|
return array(
|
|
'ERR_BAD_REVISION' => 'No such revision exists.',
|
|
);
|
|
}
|
|
|
|
protected function execute(ConduitAPIRequest $request) {
|
|
$diff = null;
|
|
|
|
$revision_id = $request->getValue('revision_id');
|
|
$revision = id(new DifferentialRevisionQuery())
|
|
->withIDs(array($revision_id))
|
|
->setViewer($request->getUser())
|
|
->needRelationships(true)
|
|
->needReviewerStatus(true)
|
|
->executeOne();
|
|
|
|
if (!$revision) {
|
|
throw new ConduitException('ERR_BAD_REVISION');
|
|
}
|
|
|
|
$reviewer_phids = array_values($revision->getReviewers());
|
|
|
|
$diffs = id(new DifferentialDiffQuery())
|
|
->setViewer($request->getUser())
|
|
->withRevisionIDs(array($revision_id))
|
|
->needChangesets(true)
|
|
->needArcanistProjects(true)
|
|
->execute();
|
|
$diff_dicts = mpull($diffs, 'getDiffDict');
|
|
|
|
$commit_dicts = array();
|
|
$commit_phids = $revision->loadCommitPHIDs();
|
|
$handles = id(new PhabricatorHandleQuery())
|
|
->setViewer($request->getUser())
|
|
->withPHIDs($commit_phids)
|
|
->execute();
|
|
|
|
foreach ($commit_phids as $commit_phid) {
|
|
$commit_dicts[] = array(
|
|
'fullname' => $handles[$commit_phid]->getFullName(),
|
|
'dateCommitted' => $handles[$commit_phid]->getTimestamp(),
|
|
);
|
|
}
|
|
|
|
$field_data = $this->loadCustomFieldsForRevisions(
|
|
$request->getUser(),
|
|
array($revision));
|
|
|
|
$dict = array(
|
|
'id' => $revision->getID(),
|
|
'phid' => $revision->getPHID(),
|
|
'authorPHID' => $revision->getAuthorPHID(),
|
|
'uri' => PhabricatorEnv::getURI('/D'.$revision->getID()),
|
|
'title' => $revision->getTitle(),
|
|
'status' => $revision->getStatus(),
|
|
'statusName' =>
|
|
ArcanistDifferentialRevisionStatus::getNameForRevisionStatus(
|
|
$revision->getStatus()),
|
|
'summary' => $revision->getSummary(),
|
|
'testPlan' => $revision->getTestPlan(),
|
|
'lineCount' => $revision->getLineCount(),
|
|
'reviewerPHIDs' => $reviewer_phids,
|
|
'diffs' => $diff_dicts,
|
|
'commits' => $commit_dicts,
|
|
'auxiliary' => idx($field_data, $revision->getPHID(), array())
|
|
);
|
|
|
|
return $dict;
|
|
}
|
|
|
|
}
|