2013-07-15 04:18:55 +02:00
|
|
|
<?php
|
|
|
|
|
2015-06-15 10:02:26 +02:00
|
|
|
final class DifferentialReviewer extends Phobject {
|
2013-07-15 04:18:55 +02:00
|
|
|
|
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() {
|
2014-07-24 00:05:46 +02:00
|
|
|
$user_type = PhabricatorPeopleUserPHIDType::TYPECONST;
|
2013-10-05 16:54:42 +02:00
|
|
|
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)) {
|
2015-05-22 09:27:56 +02:00
|
|
|
throw new Exception(pht('You must %s first!', 'attachAuthority()'));
|
2013-10-07 02:08:14 +02:00
|
|
|
}
|
|
|
|
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
|
|
|
}
|