Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / project / trigger / PhabricatorProjectTriggerManiphestStatusRule.php
blob85d32134e46749bb2181c6765da912fb73eee971
1 <?php
3 final class PhabricatorProjectTriggerManiphestStatusRule
4 extends PhabricatorProjectTriggerRule {
6 const TRIGGERTYPE = 'task.status';
8 public function getSelectControlName() {
9 return pht('Change status to');
12 protected function assertValidRuleRecordFormat($value) {
13 if (!is_string($value)) {
14 throw new Exception(
15 pht(
16 'Status rule value should be a string, but is not (value is "%s").',
17 phutil_describe_type($value)));
21 protected function assertValidRuleRecordValue($value) {
22 $map = ManiphestTaskStatus::getTaskStatusMap();
23 if (!isset($map[$value])) {
24 throw new Exception(
25 pht(
26 'Task status value ("%s") is not a valid task status. '.
27 'Valid statues are: %s.',
28 $value,
29 implode(', ', array_keys($map))));
33 protected function newDropTransactions($object, $value) {
34 return array(
35 $this->newTransaction()
36 ->setTransactionType(ManiphestTaskStatusTransaction::TRANSACTIONTYPE)
37 ->setNewValue($value),
41 protected function newDropEffects($value) {
42 $status_name = ManiphestTaskStatus::getTaskStatusName($value);
43 $status_icon = ManiphestTaskStatus::getStatusIcon($value);
44 $status_color = ManiphestTaskStatus::getStatusColor($value);
46 $content = pht(
47 'Change status to %s.',
48 phutil_tag('strong', array(), $status_name));
50 return array(
51 $this->newEffect()
52 ->setIcon($status_icon)
53 ->setColor($status_color)
54 ->addCondition('status', '!=', $value)
55 ->setContent($content),
59 protected function getDefaultValue() {
60 return ManiphestTaskStatus::getDefaultClosedStatus();
63 protected function getPHUIXControlType() {
64 return 'select';
67 protected function getPHUIXControlSpecification() {
68 $map = ManiphestTaskStatus::getTaskStatusMap();
70 return array(
71 'options' => $map,
72 'order' => array_keys($map),
76 public function getRuleViewLabel() {
77 return pht('Change Status');
80 public function getRuleViewDescription($value) {
81 $status_name = ManiphestTaskStatus::getTaskStatusName($value);
83 return pht(
84 'Change task status to %s.',
85 phutil_tag('strong', array(), $status_name));
88 public function getRuleViewIcon($value) {
89 $status_icon = ManiphestTaskStatus::getStatusIcon($value);
90 $status_color = ManiphestTaskStatus::getStatusColor($value);
92 return id(new PHUIIconView())
93 ->setIcon($status_icon, $status_color);