From db1f94b0c05a75c3f3a07c8ca28c25e77bbbce05 Mon Sep 17 00:00:00 2001 From: vrana Date: Fri, 18 May 2012 00:33:21 -0700 Subject: [PATCH] Move getPrimaryReviewer() to DifferentialRevision Test Plan: Display revision list both with last reviewer and without. Reviewers: epriestley, btrahan Reviewed By: btrahan CC: aran, Koolvin Differential Revision: https://secure.phabricator.com/D2495 --- .../DifferentialReviewersFieldSpecification.php | 12 ++---------- .../storage/revision/DifferentialRevision.php | 7 +++++++ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/applications/differential/field/specification/reviewers/DifferentialReviewersFieldSpecification.php b/src/applications/differential/field/specification/reviewers/DifferentialReviewersFieldSpecification.php index 1d6546cd05..1117ade5cc 100644 --- a/src/applications/differential/field/specification/reviewers/DifferentialReviewersFieldSpecification.php +++ b/src/applications/differential/field/specification/reviewers/DifferentialReviewersFieldSpecification.php @@ -140,7 +140,7 @@ final class DifferentialReviewersFieldSpecification } public function renderValueForRevisionList(DifferentialRevision $revision) { - $primary_reviewer = $this->getPrimaryReviewer($revision); + $primary_reviewer = $revision->getPrimaryReviewer(); if ($primary_reviewer) { $other_reviewers = array_flip($revision->getReviewers()); unset($other_reviewers[$primary_reviewer]); @@ -157,19 +157,11 @@ final class DifferentialReviewersFieldSpecification public function getRequiredHandlePHIDsForRevisionList( DifferentialRevision $revision) { - $primary_reviewer = $this->getPrimaryReviewer($revision); + $primary_reviewer = $revision->getPrimaryReviewer(); if ($primary_reviewer) { return array($primary_reviewer); } return array(); } - private function getPrimaryReviewer(DifferentialRevision $revision) { - $primary_reviewer = $revision->getLastReviewerPHID(); - if (!$primary_reviewer) { - $primary_reviewer = head($revision->getReviewers()); - } - return $primary_reviewer; - } - } diff --git a/src/applications/differential/storage/revision/DifferentialRevision.php b/src/applications/differential/storage/revision/DifferentialRevision.php index 5e5303a30a..218470b656 100644 --- a/src/applications/differential/storage/revision/DifferentialRevision.php +++ b/src/applications/differential/storage/revision/DifferentialRevision.php @@ -206,6 +206,13 @@ final class DifferentialRevision extends DifferentialDAO { return array_keys($this->getUnsubscribed()); } + public function getPrimaryReviewer() { + if (!$this->lastReviewerPHID) { + return head($this->getReviewers()); + } + return $this->lastReviewerPHID; + } + public function loadReviewedBy() { $reviewer = null;