3 abstract class DifferentialReviewersHeraldAction
6 const DO_AUTHORS
= 'do.authors';
7 const DO_ADD_REVIEWERS
= 'do.add-reviewers';
8 const DO_ADD_BLOCKING_REVIEWERS
= 'do.add-blocking-reviewers';
10 public function getActionGroupKey() {
11 return HeraldApplicationActionGroup
::ACTIONGROUPKEY
;
14 public function supportsObject($object) {
15 return ($object instanceof DifferentialRevision
);
18 protected function applyReviewers(array $phids, $is_blocking) {
19 $adapter = $this->getAdapter();
20 $object = $adapter->getObject();
22 $phids = array_fuse($phids);
24 // Don't try to add revision authors as reviewers.
26 foreach ($phids as $phid) {
27 if ($phid == $object->getAuthorPHID()) {
34 $this->logEffect(self
::DO_AUTHORS
, $authors);
40 $reviewers = $object->getReviewers();
43 $new_status = DifferentialReviewerStatus
::STATUS_BLOCKING
;
45 $new_status = DifferentialReviewerStatus
::STATUS_ADDED
;
48 $new_strength = DifferentialReviewerStatus
::getStatusStrength(
52 foreach ($phids as $phid) {
53 if (!isset($reviewers[$phid])) {
57 // If we're applying a stronger status (usually, upgrading a reviewer
58 // into a blocking reviewer), skip this check so we apply the change.
59 $old_strength = DifferentialReviewerStatus
::getStatusStrength(
60 $reviewers[$phid]->getReviewerStatus());
61 if ($old_strength <= $new_strength) {
68 $allowed_types = array(
69 PhabricatorPeopleUserPHIDType
::TYPECONST
,
70 PhabricatorProjectProjectPHIDType
::TYPECONST
,
71 PhabricatorOwnersPackagePHIDType
::TYPECONST
,
74 $targets = $this->loadStandardTargets($phids, $allowed_types, $current);
79 $phids = array_fuse(array_keys($targets));
82 foreach ($phids as $phid) {
84 $value[] = 'blocking('.$phid.')';
90 $reviewers_type = DifferentialRevisionReviewersTransaction
::TRANSACTIONTYPE
;
92 $xaction = $adapter->newTransaction()
93 ->setTransactionType($reviewers_type)
99 $adapter->queueTransaction($xaction);
102 $this->logEffect(self
::DO_ADD_BLOCKING_REVIEWERS
, $phids);
104 $this->logEffect(self
::DO_ADD_REVIEWERS
, $phids);
108 protected function getActionEffectMap() {
110 self
::DO_AUTHORS
=> array(
113 'name' => pht('Revision Author'),
115 self
::DO_ADD_REVIEWERS
=> array(
118 'name' => pht('Added Reviewers'),
120 self
::DO_ADD_BLOCKING_REVIEWERS
=> array(
123 'name' => pht('Added Blocking Reviewers'),
128 protected function renderActionEffectDescription($type, $data) {
130 case self
::DO_AUTHORS
:
132 'Declined to add revision author as reviewer: %s.',
133 $this->renderHandleList($data));
134 case self
::DO_ADD_REVIEWERS
:
136 'Added %s reviewer(s): %s.',
138 $this->renderHandleList($data));
139 case self
::DO_ADD_BLOCKING_REVIEWERS
:
141 'Added %s blocking reviewer(s): %s.',
143 $this->renderHandleList($data));