@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at upstream/main 87 lines 2.1 kB view raw
1<?php 2 3final class DiffusionCommitAcceptTransaction 4 extends DiffusionCommitAuditTransaction { 5 6 const TRANSACTIONTYPE = 'diffusion.commit.accept'; 7 const ACTIONKEY = 'accept'; 8 9 protected function getCommitActionLabel() { 10 return pht('Accept Commit'); 11 } 12 13 protected function getCommitActionDescription() { 14 return pht('This commit will be approved.'); 15 } 16 17 /** 18 * @return string Transaction icon 19 */ 20 public function getIcon() { 21 return 'fa-check-circle-o'; 22 } 23 24 /** 25 * @return string Transaction color 26 */ 27 public function getColor() { 28 return 'green'; 29 } 30 31 protected function getCommitActionOrder() { 32 return 500; 33 } 34 35 public function getActionName() { 36 return pht('Accepted'); 37 } 38 39 public function applyExternalEffects($object, $value) { 40 $status = PhabricatorAuditRequestStatus::ACCEPTED; 41 $actor = $this->getActor(); 42 $this->applyAuditorEffect($object, $actor, $value, $status); 43 } 44 45 protected function validateAction($object, PhabricatorUser $viewer) { 46 $config_key = 'audit.can-author-close-audit'; 47 if (!PhabricatorEnv::getEnvConfig($config_key)) { 48 if ($this->isViewerCommitAuthor($object, $viewer)) { 49 throw new Exception( 50 pht( 51 'You can not accept this commit because you are the commit '. 52 'author. You can only accept commits you did not author. You can '. 53 'change this behavior by adjusting the "%s" setting in Config.', 54 $config_key)); 55 } 56 } 57 58 if ($this->isViewerFullyAccepted($object, $viewer)) { 59 throw new Exception( 60 pht( 61 'You can not accept this commit because you have already '. 62 'accepted it.')); 63 } 64 } 65 66 public function getTitle() { 67 return pht( 68 '%s accepted this commit.', 69 $this->renderAuthor()); 70 } 71 72 public function getTitleForFeed() { 73 return pht( 74 '%s accepted %s.', 75 $this->renderAuthor(), 76 $this->renderObject()); 77 } 78 79 public function getTransactionTypeForConduit($xaction) { 80 return 'accept'; 81 } 82 83 public function getFieldValuesForConduit($object, $data) { 84 return array(); 85 } 86 87}