diff --git a/src/applications/conduit/method/differential/getrevision/ConduitAPI_differential_getrevision_Method.php b/src/applications/conduit/method/differential/getrevision/ConduitAPI_differential_getrevision_Method.php index a633d3e6d1..35d2f09778 100644 --- a/src/applications/conduit/method/differential/getrevision/ConduitAPI_differential_getrevision_Method.php +++ b/src/applications/conduit/method/differential/getrevision/ConduitAPI_differential_getrevision_Method.php @@ -78,6 +78,8 @@ class ConduitAPI_differential_getrevision_Method extends ConduitAPIMethod { ); } + $auxiliary_fields = $this->loadAuxiliaryFields($revision); + $dict = array( 'id' => $revision->getID(), 'phid' => $revision->getPHID(), @@ -95,9 +97,26 @@ class ConduitAPI_differential_getrevision_Method extends ConduitAPIMethod { 'reviewerPHIDs' => $reviewer_phids, 'diffs' => $diff_dicts, 'commits' => $commit_dicts, + 'auxiliary' => $auxiliary_fields, ); 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'); + } + } diff --git a/src/applications/conduit/method/differential/getrevision/__init__.php b/src/applications/conduit/method/differential/getrevision/__init__.php index 64388c9bea..66949aaa71 100644 --- a/src/applications/conduit/method/differential/getrevision/__init__.php +++ b/src/applications/conduit/method/differential/getrevision/__init__.php @@ -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/protocol/exception'); 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/phid/handle/data'); phutil_require_module('phabricator', 'infrastructure/env'); diff --git a/src/applications/differential/field/exception/incomplete/DifferentialFieldSpecificationIncompleteException.php b/src/applications/differential/field/exception/incomplete/DifferentialFieldSpecificationIncompleteException.php index 32a9bbee5a..fb96c4c93e 100644 --- a/src/applications/differential/field/exception/incomplete/DifferentialFieldSpecificationIncompleteException.php +++ b/src/applications/differential/field/exception/incomplete/DifferentialFieldSpecificationIncompleteException.php @@ -18,7 +18,7 @@ class DifferentialFieldSpecificationIncompleteException extends Exception { - public function __construct(DifferentialFieldSpecification $spec, $claim) { + public function __construct(DifferentialFieldSpecification $spec) { $key = $spec->getStorageKey(); $class = get_class($spec); diff --git a/src/applications/differential/field/specification/base/DifferentialFieldSpecification.php b/src/applications/differential/field/specification/base/DifferentialFieldSpecification.php index 18ab2fed5a..5376bb1ec2 100644 --- a/src/applications/differential/field/specification/base/DifferentialFieldSpecification.php +++ b/src/applications/differential/field/specification/base/DifferentialFieldSpecification.php @@ -27,6 +27,7 @@ * @task storage Field Storage * @task edit Extending the Revision Edit Interface * @task view Extending the Revision View Interface + * @task conduit Extending the Conduit View Interface */ 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); + } + } diff --git a/src/applications/differential/field/specification/blamerev/DifferentialBlameRevisionFieldSpecification.php b/src/applications/differential/field/specification/blamerev/DifferentialBlameRevisionFieldSpecification.php index 54de5290f7..a47b0ae429 100644 --- a/src/applications/differential/field/specification/blamerev/DifferentialBlameRevisionFieldSpecification.php +++ b/src/applications/differential/field/specification/blamerev/DifferentialBlameRevisionFieldSpecification.php @@ -70,4 +70,12 @@ final class DifferentialBlameRevisionFieldSpecification return phutil_escape_html($this->value); } + public function shouldAppearOnConduitView() { + return true; + } + + public function getValueForConduit() { + return $this->value; + } + } diff --git a/src/applications/differential/field/specification/revertplan/DifferentialRevertPlanFieldSpecification.php b/src/applications/differential/field/specification/revertplan/DifferentialRevertPlanFieldSpecification.php index 80fe189f8b..4a4af01f45 100644 --- a/src/applications/differential/field/specification/revertplan/DifferentialRevertPlanFieldSpecification.php +++ b/src/applications/differential/field/specification/revertplan/DifferentialRevertPlanFieldSpecification.php @@ -70,4 +70,12 @@ final class DifferentialRevertPlanFieldSpecification return phutil_escape_html($this->value); } + public function shouldAppearOnConduitView() { + return true; + } + + public function getValueForConduit() { + return $this->value; + } + }