Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/owners/constants/PhabricatorOwnersAuditRule.php
12256 views
1
<?php
2
3
final class PhabricatorOwnersAuditRule
4
extends Phobject {
5
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';
11
12
private $key;
13
private $spec;
14
15
public static function newFromState($key) {
16
$specs = self::newSpecifications();
17
$spec = idx($specs, $key, array());
18
19
$rule = new self();
20
$rule->key = $key;
21
$rule->spec = $spec;
22
23
return $rule;
24
}
25
26
public function getKey() {
27
return $this->key;
28
}
29
30
public function getDisplayName() {
31
return idx($this->spec, 'name', $this->key);
32
}
33
34
public function getIconIcon() {
35
return idx($this->spec, 'icon.icon');
36
}
37
38
public static function newSelectControlMap() {
39
$specs = self::newSpecifications();
40
return ipull($specs, 'name');
41
}
42
43
public static function getStorageValueFromAPIValue($value) {
44
$specs = self::newSpecifications();
45
46
$map = array();
47
foreach ($specs as $key => $spec) {
48
$deprecated = idx($spec, 'deprecated', array());
49
if (isset($deprecated[$value])) {
50
return $key;
51
}
52
}
53
54
return $value;
55
}
56
57
public static function getModernValueMap() {
58
$specs = self::newSpecifications();
59
60
$map = array();
61
foreach ($specs as $key => $spec) {
62
$map[$key] = pht('"%s"', $key);
63
}
64
65
return $map;
66
}
67
68
public static function getDeprecatedValueMap() {
69
$specs = self::newSpecifications();
70
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;
76
}
77
}
78
79
return $map;
80
}
81
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"',
90
),
91
),
92
self::AUDITING_UNREVIEWED => array(
93
'name' => pht('Audit Unreviewed Commits'),
94
'icon.icon' => 'fa-check',
95
),
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"',
101
),
102
),
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',
107
),
108
self::AUDITING_ALL => array(
109
'name' => pht('Audit All Commits'),
110
'icon.icon' => 'fa-check',
111
),
112
);
113
}
114
115
116
117
}
118
119