mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 03:50:54 +01:00
Expose Differential auxiliary fields in Conduit
Summary: Similar to D785 for Maniphest, expose auxiliary field values via Conduit. Test Plan: Ran revision.getinfo on a revision with aux fields, got them in the response. Reviewed By: jungejason Reviewers: jungejason, tuomaspelkonen, aran CC: aran, jungejason Differential Revision: 802
This commit is contained in:
parent
e196bf5b43
commit
7aa1eff383
6 changed files with 56 additions and 1 deletions
|
@ -78,6 +78,8 @@ class ConduitAPI_differential_getrevision_Method extends ConduitAPIMethod {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$auxiliary_fields = $this->loadAuxiliaryFields($revision);
|
||||||
|
|
||||||
$dict = array(
|
$dict = array(
|
||||||
'id' => $revision->getID(),
|
'id' => $revision->getID(),
|
||||||
'phid' => $revision->getPHID(),
|
'phid' => $revision->getPHID(),
|
||||||
|
@ -95,9 +97,26 @@ class ConduitAPI_differential_getrevision_Method extends ConduitAPIMethod {
|
||||||
'reviewerPHIDs' => $reviewer_phids,
|
'reviewerPHIDs' => $reviewer_phids,
|
||||||
'diffs' => $diff_dicts,
|
'diffs' => $diff_dicts,
|
||||||
'commits' => $commit_dicts,
|
'commits' => $commit_dicts,
|
||||||
|
'auxiliary' => $auxiliary_fields,
|
||||||
);
|
);
|
||||||
|
|
||||||
return $dict;
|
return $dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function loadAuxiliaryFields(DifferentialRevision $revision) {
|
||||||
|
$aux_fields = DifferentialFieldSelector::newSelector()
|
||||||
|
->getFieldSpecifications();
|
||||||
|
foreach ($aux_fields as $key => $aux_field) {
|
||||||
|
if (!$aux_field->shouldAppearOnConduitView()) {
|
||||||
|
unset($aux_fields[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$aux_fields = DifferentialAuxiliaryField::loadFromStorage(
|
||||||
|
$revision,
|
||||||
|
$aux_fields);
|
||||||
|
|
||||||
|
return mpull($aux_fields, 'getValueForConduit', 'getStorageKey');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@ phutil_require_module('phabricator', 'applications/conduit/method/base');
|
||||||
phutil_require_module('phabricator', 'applications/conduit/method/differential/getdiff');
|
phutil_require_module('phabricator', 'applications/conduit/method/differential/getdiff');
|
||||||
phutil_require_module('phabricator', 'applications/conduit/protocol/exception');
|
phutil_require_module('phabricator', 'applications/conduit/protocol/exception');
|
||||||
phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus');
|
phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus');
|
||||||
|
phutil_require_module('phabricator', 'applications/differential/field/selector/base');
|
||||||
|
phutil_require_module('phabricator', 'applications/differential/storage/auxiliaryfield');
|
||||||
phutil_require_module('phabricator', 'applications/differential/storage/revision');
|
phutil_require_module('phabricator', 'applications/differential/storage/revision');
|
||||||
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||||
phutil_require_module('phabricator', 'infrastructure/env');
|
phutil_require_module('phabricator', 'infrastructure/env');
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
class DifferentialFieldSpecificationIncompleteException extends Exception {
|
class DifferentialFieldSpecificationIncompleteException extends Exception {
|
||||||
|
|
||||||
public function __construct(DifferentialFieldSpecification $spec, $claim) {
|
public function __construct(DifferentialFieldSpecification $spec) {
|
||||||
$key = $spec->getStorageKey();
|
$key = $spec->getStorageKey();
|
||||||
$class = get_class($spec);
|
$class = get_class($spec);
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
* @task storage Field Storage
|
* @task storage Field Storage
|
||||||
* @task edit Extending the Revision Edit Interface
|
* @task edit Extending the Revision Edit Interface
|
||||||
* @task view Extending the Revision View Interface
|
* @task view Extending the Revision View Interface
|
||||||
|
* @task conduit Extending the Conduit View Interface
|
||||||
*/
|
*/
|
||||||
abstract class DifferentialFieldSpecification {
|
abstract class DifferentialFieldSpecification {
|
||||||
|
|
||||||
|
@ -131,4 +132,21 @@ abstract class DifferentialFieldSpecification {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -( Extending the Conduit Interface )------------------------------------ */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @task conduit
|
||||||
|
*/
|
||||||
|
public function shouldAppearOnConduitView() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @task conduit
|
||||||
|
*/
|
||||||
|
public function getValueForConduit() {
|
||||||
|
throw new DifferentialFieldSpecificationIncompleteException($this);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,4 +70,12 @@ final class DifferentialBlameRevisionFieldSpecification
|
||||||
return phutil_escape_html($this->value);
|
return phutil_escape_html($this->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function shouldAppearOnConduitView() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getValueForConduit() {
|
||||||
|
return $this->value;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,4 +70,12 @@ final class DifferentialRevertPlanFieldSpecification
|
||||||
return phutil_escape_html($this->value);
|
return phutil_escape_html($this->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function shouldAppearOnConduitView() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getValueForConduit() {
|
||||||
|
return $this->value;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue