@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
1<?php
2
3final class PhabricatorAuditRequestStatus extends Phobject {
4
5 const AUDIT_REQUIRED = 'audit-required';
6 const CONCERNED = 'concerned';
7 const ACCEPTED = 'accepted';
8 const AUDIT_REQUESTED = 'requested';
9 const RESIGNED = 'resigned';
10
11 private $key;
12
13 public static function newForStatus($status) {
14 $result = new self();
15 $result->key = $status;
16 return $result;
17 }
18
19 public function getIconIcon() {
20 return $this->getMapProperty('icon');
21 }
22
23 public function getIconColor() {
24 return $this->getMapProperty('icon.color');
25 }
26
27 public function getStatusName() {
28 $name = $this->getMapProperty('name');
29 if ($name !== null) {
30 return $name;
31 }
32
33 return pht('Unknown Audit Request Status ("%s")', $this->key);
34 }
35
36 public function getStatusValue() {
37 return $this->key;
38 }
39
40 public function getStatusValueForConduit() {
41 return $this->getMapProperty('value.conduit');
42 }
43
44 public function isResigned() {
45 return ($this->key === self::RESIGNED);
46 }
47
48 private function getMapProperty($key, $default = null) {
49 $map = self::newStatusMap();
50 $spec = idx($map, $this->key, array());
51 return idx($spec, $key, $default);
52 }
53
54 private static function newStatusMap() {
55 return array(
56 self::AUDIT_REQUIRED => array(
57 'name' => pht('Audit Required'),
58 'icon' => 'fa-exclamation-circle',
59 'icon.color' => 'orange',
60 'value.conduit' => 'audit-required',
61 ),
62 self::AUDIT_REQUESTED => array(
63 'name' => pht('Audit Requested'),
64 'icon' => 'fa-exclamation-circle',
65 'icon.color' => 'orange',
66 'value.conduit' => 'audit-requested',
67 ),
68 self::CONCERNED => array(
69 'name' => pht('Concern Raised'),
70 'icon' => 'fa-times-circle',
71 'icon.color' => 'red',
72 'value.conduit' => 'concern-raised',
73 ),
74 self::ACCEPTED => array(
75 'name' => pht('Accepted'),
76 'icon' => 'fa-check-circle',
77 'icon.color' => 'green',
78 'value.conduit' => 'accepted',
79 ),
80 self::RESIGNED => array(
81 'name' => pht('Resigned'),
82 'icon' => 'fa-times',
83 'icon.color' => 'grey',
84 'value.conduit' => 'resigned',
85 ),
86 );
87 }
88
89}