3 abstract class DiffusionAuditorsHeraldAction
6 const DO_AUTHORS
= 'do.authors';
7 const DO_ADD_AUDITORS
= 'do.add-auditors';
9 public function getActionGroupKey() {
10 return HeraldApplicationActionGroup
::ACTIONGROUPKEY
;
13 public function supportsObject($object) {
14 return ($object instanceof PhabricatorRepositoryCommit
);
17 protected function applyAuditors(array $phids, HeraldRule
$rule) {
18 $adapter = $this->getAdapter();
19 $object = $adapter->getObject();
21 $auditors = $object->getAudits();
23 // Don't try to add commit authors as auditors.
25 foreach ($phids as $key => $phid) {
26 if ($phid == $object->getAuthorPHID()) {
33 $this->logEffect(self
::DO_AUTHORS
, $authors);
40 foreach ($auditors as $auditor) {
41 $current[] = $auditor->getAuditorPHID();
44 $allowed_types = array(
45 PhabricatorPeopleUserPHIDType
::TYPECONST
,
46 PhabricatorProjectProjectPHIDType
::TYPECONST
,
47 PhabricatorOwnersPackagePHIDType
::TYPECONST
,
50 $targets = $this->loadStandardTargets($phids, $allowed_types, $current);
55 $phids = array_fuse(array_keys($targets));
57 $xaction = $adapter->newTransaction()
58 ->setTransactionType(DiffusionCommitAuditorsTransaction
::TRANSACTIONTYPE
)
64 $adapter->queueTransaction($xaction);
66 $this->logEffect(self
::DO_ADD_AUDITORS
, $phids);
69 protected function getActionEffectMap() {
71 self
::DO_AUTHORS
=> array(
74 'name' => pht('Commit Author'),
76 self
::DO_ADD_AUDITORS
=> array(
79 'name' => pht('Added Auditors'),
84 protected function renderActionEffectDescription($type, $data) {
86 case self
::DO_AUTHORS
:
88 'Declined to add commit author as auditor: %s.',
89 $this->renderHandleList($data));
90 case self
::DO_ADD_AUDITORS
:
92 'Added %s auditor(s): %s.',
94 $this->renderHandleList($data));