Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / owners / constants / PhabricatorOwnersAuditRule.php
blob32a9bb804b6da941f84ce59e99c23949ebd29d49
1 <?php
3 final class PhabricatorOwnersAuditRule
4 extends Phobject {
6 const AUDITING_NONE = 'none';
7 const AUDITING_NO_OWNER = 'audit';
8 const AUDITING_UNREVIEWED = 'unreviewed';
9 const AUDITING_NO_OWNER_AND_UNREVIEWED = 'uninvolved-unreviewed';
10 const AUDITING_ALL = 'all';
12 private $key;
13 private $spec;
15 public static function newFromState($key) {
16 $specs = self::newSpecifications();
17 $spec = idx($specs, $key, array());
19 $rule = new self();
20 $rule->key = $key;
21 $rule->spec = $spec;
23 return $rule;
26 public function getKey() {
27 return $this->key;
30 public function getDisplayName() {
31 return idx($this->spec, 'name', $this->key);
34 public function getIconIcon() {
35 return idx($this->spec, 'icon.icon');
38 public static function newSelectControlMap() {
39 $specs = self::newSpecifications();
40 return ipull($specs, 'name');
43 public static function getStorageValueFromAPIValue($value) {
44 $specs = self::newSpecifications();
46 $map = array();
47 foreach ($specs as $key => $spec) {
48 $deprecated = idx($spec, 'deprecated', array());
49 if (isset($deprecated[$value])) {
50 return $key;
54 return $value;
57 public static function getModernValueMap() {
58 $specs = self::newSpecifications();
60 $map = array();
61 foreach ($specs as $key => $spec) {
62 $map[$key] = pht('"%s"', $key);
65 return $map;
68 public static function getDeprecatedValueMap() {
69 $specs = self::newSpecifications();
71 $map = array();
72 foreach ($specs as $key => $spec) {
73 $deprecated_map = idx($spec, 'deprecated', array());
74 foreach ($deprecated_map as $deprecated_key => $label) {
75 $map[$deprecated_key] = $label;
79 return $map;
82 private static function newSpecifications() {
83 return array(
84 self::AUDITING_NONE => array(
85 'name' => pht('No Auditing'),
86 'icon.icon' => 'fa-ban',
87 'deprecated' => array(
88 '' => pht('"" (empty string)'),
89 '0' => '"0"',
92 self::AUDITING_UNREVIEWED => array(
93 'name' => pht('Audit Unreviewed Commits'),
94 'icon.icon' => 'fa-check',
96 self::AUDITING_NO_OWNER => array(
97 'name' => pht('Audit Commits With No Owner Involvement'),
98 'icon.icon' => 'fa-check',
99 'deprecated' => array(
100 '1' => '"1"',
103 self::AUDITING_NO_OWNER_AND_UNREVIEWED => array(
104 'name' => pht(
105 'Audit Unreviewed Commits and Commits With No Owner Involvement'),
106 'icon.icon' => 'fa-check',
108 self::AUDITING_ALL => array(
109 'name' => pht('Audit All Commits'),
110 'icon.icon' => 'fa-check',