[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/differential/storage/ -> DifferentialReviewer.php (source)

   1  <?php
   2  
   3  final class DifferentialReviewer {
   4  
   5    private $reviewerPHID;
   6    private $status;
   7    private $diffID;
   8    private $authority = array();
   9  
  10    public function __construct($reviewer_phid, array $edge_data) {
  11      $this->reviewerPHID = $reviewer_phid;
  12      $this->status = idx($edge_data, 'status');
  13      $this->diffID = idx($edge_data, 'diff');
  14    }
  15  
  16    public function getReviewerPHID() {
  17      return $this->reviewerPHID;
  18    }
  19  
  20    public function getStatus() {
  21      return $this->status;
  22    }
  23  
  24    public function getDiffID() {
  25      return $this->diffID;
  26    }
  27  
  28    public function isUser() {
  29      $user_type = PhabricatorPeopleUserPHIDType::TYPECONST;
  30      return (phid_get_type($this->getReviewerPHID()) == $user_type);
  31    }
  32  
  33    public function attachAuthority(PhabricatorUser $user, $has_authority) {
  34      $this->authority[$user->getPHID()] = $has_authority;
  35      return $this;
  36    }
  37  
  38    public function hasAuthority(PhabricatorUser $viewer) {
  39      // It would be nice to use assertAttachedKey() here, but we don't extend
  40      // PhabricatorLiskDAO, and faking that seems sketchy.
  41  
  42      $viewer_phid = $viewer->getPHID();
  43      if (!array_key_exists($viewer_phid, $this->authority)) {
  44        throw new Exception('You must attachAuthority() first!');
  45      }
  46      return $this->authority[$viewer_phid];
  47    }
  48  
  49    public function getEdgeData() {
  50      return array(
  51        'status' => $this->status,
  52        'diffID' => $this->diffID,
  53      );
  54    }
  55  
  56  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1