@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 93 lines 1.9 kB view raw
1<?php 2 3final class PhabricatorProjectTriggerInvalidRule 4 extends PhabricatorProjectTriggerRule { 5 6 const TRIGGERTYPE = 'invalid'; 7 8 private $exception; 9 10 public function setException(Exception $exception) { 11 $this->exception = $exception; 12 return $this; 13 } 14 15 public function getException() { 16 return $this->exception; 17 } 18 19 public function getSelectControlName() { 20 return pht('(Invalid Rule)'); 21 } 22 23 protected function isSelectableRule() { 24 return false; 25 } 26 27 protected function assertValidRuleRecordFormat($value) { 28 return; 29 } 30 31 protected function newDropTransactions($object, $value) { 32 return array(); 33 } 34 35 protected function newDropEffects($value) { 36 return array(); 37 } 38 39 protected function isValidRule() { 40 return false; 41 } 42 43 protected function newInvalidView() { 44 return array( 45 id(new PHUIIconView()) 46 ->setIcon('fa-exclamation-triangle red'), 47 ' ', 48 pht( 49 'This is a trigger rule with a valid type ("%s") but an invalid '. 50 'value.', 51 $this->getRecord()->getType()), 52 ); 53 } 54 55 protected function getDefaultValue() { 56 return null; 57 } 58 59 protected function getPHUIXControlType() { 60 return null; 61 } 62 63 protected function getPHUIXControlSpecification() { 64 return null; 65 } 66 67 public function getRuleViewLabel() { 68 return pht('Invalid Rule'); 69 } 70 71 public function getRuleViewDescription($value) { 72 $record = $this->getRecord(); 73 $type = $record->getType(); 74 75 $exception = $this->getException(); 76 if ($exception) { 77 return pht( 78 'This rule (of type "%s") is invalid: %s', 79 $type, 80 $exception->getMessage()); 81 } else { 82 return pht( 83 'This rule (of type "%s") is invalid.', 84 $type); 85 } 86 } 87 88 public function getRuleViewIcon($value) { 89 return id(new PHUIIconView()) 90 ->setIcon('fa-exclamation-triangle', 'red'); 91 } 92 93}