Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / project / trigger / PhabricatorProjectTriggerManiphestPriorityRule.php
blob56b0fc9b1faef3d9898eac3e18af9b27c0404513
1 <?php
3 final class PhabricatorProjectTriggerManiphestPriorityRule
4 extends PhabricatorProjectTriggerRule {
6 const TRIGGERTYPE = 'task.priority';
8 public function getSelectControlName() {
9 return pht('Change priority to');
12 protected function assertValidRuleRecordFormat($value) {
13 if (!is_string($value)) {
14 throw new Exception(
15 pht(
16 'Priority rule value should be a string, but is not (value is "%s").',
17 phutil_describe_type($value)));
21 protected function assertValidRuleRecordValue($value) {
22 $map = ManiphestTaskPriority::getTaskPriorityMap();
23 if (!isset($map[$value])) {
24 throw new Exception(
25 pht(
26 'Task priority value ("%s") is not a valid task priority. '.
27 'Valid priorities are: %s.',
28 $value,
29 implode(', ', array_keys($map))));
33 protected function newDropTransactions($object, $value) {
34 $value = ManiphestTaskPriority::getKeywordForTaskPriority($value);
35 return array(
36 $this->newTransaction()
37 ->setTransactionType(ManiphestTaskPriorityTransaction::TRANSACTIONTYPE)
38 ->setNewValue($value),
42 protected function newDropEffects($value) {
43 $priority_name = ManiphestTaskPriority::getTaskPriorityName($value);
44 $priority_icon = ManiphestTaskPriority::getTaskPriorityIcon($value);
45 $priority_color = ManiphestTaskPriority::getTaskPriorityColor($value);
47 $content = pht(
48 'Change priority to %s.',
49 phutil_tag('strong', array(), $priority_name));
51 return array(
52 $this->newEffect()
53 ->setIcon($priority_icon)
54 ->setColor($priority_color)
55 ->addCondition('priority', '!=', $value)
56 ->setContent($content),
60 protected function getDefaultValue() {
61 return ManiphestTaskPriority::getDefaultPriority();
64 protected function getPHUIXControlType() {
65 return 'select';
68 protected function getPHUIXControlSpecification() {
69 $map = ManiphestTaskPriority::getTaskPriorityMap();
71 return array(
72 'options' => $map,
73 'order' => array_keys($map),
77 public function getRuleViewLabel() {
78 return pht('Change Priority');
81 public function getRuleViewDescription($value) {
82 $priority_name = ManiphestTaskPriority::getTaskPriorityName($value);
84 return pht(
85 'Change task priority to %s.',
86 phutil_tag('strong', array(), $priority_name));
89 public function getRuleViewIcon($value) {
90 $priority_icon = ManiphestTaskPriority::getTaskPriorityIcon($value);
91 $priority_color = ManiphestTaskPriority::getTaskPriorityColor($value);
93 return id(new PHUIIconView())
94 ->setIcon($priority_icon, $priority_color);