1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Ported loadAuxiliaryFields method to differential.query conduit method

Summary: Ported the the loadAuxiliaryfields method from differential.getrevision method to modern conduit differential.query method

Test Plan: Created a test diff in differential to see if nothing has been broken

Reviewers: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5230
This commit is contained in:
Afaque Hussain 2013-03-05 05:58:04 -08:00 committed by epriestley
parent 1bb160a244
commit a521790f13

View file

@ -196,6 +196,8 @@ final class ConduitAPI_differential_query_Method
} }
$id = $revision->getID(); $id = $revision->getID();
$auxiliary_fields = $this->loadAuxiliaryFields(
$revision, $request->getUser());
$result = array( $result = array(
'id' => $id, 'id' => $id,
'phid' => $revision->getPHID(), 'phid' => $revision->getPHID(),
@ -217,6 +219,7 @@ final class ConduitAPI_differential_query_Method
'reviewers' => array_values($revision->getReviewers()), 'reviewers' => array_values($revision->getReviewers()),
'ccs' => array_values($revision->getCCPHIDs()), 'ccs' => array_values($revision->getCCPHIDs()),
'hashes' => $revision->getHashes(), 'hashes' => $revision->getHashes(),
'auxiliary' => $auxiliary_fields,
); );
// TODO: This is a hacky way to put permissions on this field until we // TODO: This is a hacky way to put permissions on this field until we
@ -230,4 +233,24 @@ final class ConduitAPI_differential_query_Method
return $results; return $results;
} }
private function loadAuxiliaryFields(
DifferentialRevision $revision,
PhabricatorUser $user) {
$aux_fields = DifferentialFieldSelector::newSelector()
->getFieldSpecifications();
foreach ($aux_fields as $key => $aux_field) {
$aux_field->setUser($user);
if (!$aux_field->shouldAppearOnConduitView()) {
unset($aux_fields[$key]);
}
}
$aux_fields = DifferentialAuxiliaryField::loadFromStorage(
$revision,
$aux_fields);
return mpull($aux_fields, 'getValueForConduit', 'getKeyForConduit');
}
} }