2013-07-15 04:18:55 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DifferentialReviewer {
|
|
|
|
|
2013-10-07 02:08:14 +02:00
|
|
|
private $reviewerPHID;
|
|
|
|
private $status;
|
|
|
|
private $diffID;
|
|
|
|
private $authority = array();
|
2013-07-15 04:18:55 +02:00
|
|
|
|
2013-10-07 02:08:14 +02:00
|
|
|
public function __construct($reviewer_phid, array $edge_data) {
|
2013-07-15 04:18:55 +02:00
|
|
|
$this->reviewerPHID = $reviewer_phid;
|
2013-10-07 02:08:14 +02:00
|
|
|
$this->status = idx($edge_data, 'status');
|
|
|
|
$this->diffID = idx($edge_data, 'diff');
|
2013-07-15 04:18:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getReviewerPHID() {
|
|
|
|
return $this->reviewerPHID;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getStatus() {
|
|
|
|
return $this->status;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDiffID() {
|
|
|
|
return $this->diffID;
|
|
|
|
}
|
|
|
|
|
2013-10-05 16:54:42 +02:00
|
|
|
public function isUser() {
|
|
|
|
$user_type = PhabricatorPeoplePHIDTypeUser::TYPECONST;
|
|
|
|
return (phid_get_type($this->getReviewerPHID()) == $user_type);
|
|
|
|
}
|
|
|
|
|
2013-10-07 02:08:14 +02:00
|
|
|
public function attachAuthority(PhabricatorUser $user, $has_authority) {
|
|
|
|
$this->authority[$user->getPHID()] = $has_authority;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hasAuthority(PhabricatorUser $viewer) {
|
|
|
|
// It would be nice to use assertAttachedKey() here, but we don't extend
|
|
|
|
// PhabricatorLiskDAO, and faking that seems sketchy.
|
|
|
|
|
|
|
|
$viewer_phid = $viewer->getPHID();
|
|
|
|
if (!array_key_exists($viewer_phid, $this->authority)) {
|
|
|
|
throw new Exception("You must attachAuthority() first!");
|
|
|
|
}
|
|
|
|
return $this->authority[$viewer_phid];
|
|
|
|
}
|
|
|
|
|
2014-02-21 20:54:32 +01:00
|
|
|
public function getEdgeData() {
|
|
|
|
return array(
|
|
|
|
'status' => $this->status,
|
|
|
|
'diffID' => $this->diffID,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-07-15 04:18:55 +02:00
|
|
|
}
|